Git Checkout 与 git bash 无限期挂起。怎么解决?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42207230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git Checkout hangs indefinitely with git bash. How to solve?
提问by jamessct
I have been working on a project in the develop branch using git bash on my work computer. I have just attempted to checkout to the master branch as I intend to merge the changes, but when I attempt to do this the command line hangs indefinitely until I kill it with CTRL + C.
我一直在我的工作计算机上使用 git bash 在开发分支中处理一个项目。我刚刚尝试检查主分支,因为我打算合并更改,但是当我尝试执行此操作时,命令行会无限期挂起,直到我用 CTRL + C 杀死它为止。
If I attempt to checkout again, I get the following error:
如果我再次尝试结帐,则会收到以下错误:
Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.
另一个 git 进程似乎正在这个存储库中运行,例如一个由“git commit”打开的编辑器。请确保所有进程都已终止,然后重试。如果它仍然失败,则该存储库中的 git 进程可能之前已崩溃:手动删除文件以继续。
However, after deleting the index.lock file, attempting to use git checkout once again simply hangs in the terminal and never makes any progress until I kill the process once again! Etc.!
但是,在删除 index.lock 文件后,再次尝试使用 git checkout 只会挂在终端中,并且在我再次终止进程之前永远不会取得任何进展!等等。!
Has anyone come across this, and if so, how did you go about solving this issue?
有没有人遇到过这个问题,如果有,你是如何解决这个问题的?
回答by spiralx
I've been having the same issue very recently and it appears to be related to Sublime Text's aggressive indexing locking files in my tree - if you're using ST then try deleting the lock file, closing ST and then running git checkout master
again.
我最近遇到了同样的问题,它似乎与我的树中 Sublime Text 的积极索引锁定文件有关 - 如果您正在使用 ST,请尝试删除锁定文件,关闭 ST 然后git checkout master
再次运行。
回答by intotecho
Related the the answer above. I had this issue with Eclipse and Git Shell on Windows.
与上面的答案相关。我在 Windows 上使用 Eclipse 和 Git Shell 时遇到了这个问题。
You may have followed these steps to get into this situation:
您可能已经按照以下步骤进入这种情况:
- Create a branch.
- Modify a file in Eclipse (or Sublime i expect) and leave it open.
- Add the file and commit then push branch to origin.
- Git status says nothing the commit.
- Try to checkout the original branch - it hangs.
- 创建一个分支。
- 在 Eclipse(或我期望的 Sublime)中修改一个文件并将其保持打开状态。
- 添加文件并提交,然后将分支推送到原点。
- Git 状态没有说明提交。
- 尝试检查原始分支 - 它挂起。
To resolve the issue:
要解决此问题:
- So Ctrl-C and delete the lock file.
Note that git status now says
modified: filename
Switch to Eclipse and it says 'file has changed on disk - with option to reload.
- Close the file in Eclipse.
- Undo the changes with
git checkout -- filename
- 所以Ctrl-C并删除锁定文件。
请注意, git status 现在说
modified: filename
切换到 Eclipse,它说“磁盘上的文件已更改 - 可以选择重新加载”。
- 在 Eclipse 中关闭该文件。
- 撤消更改
git checkout -- filename
Now it should be possible to checkout the branch.
现在应该可以结帐分支了。
回答by Bosco
I had Textpad open on a file, and I think its locking caused this (same as spiralx mentioned about Sublime Text's aggressive indexing locking files). Even though I closed Textpad, I still could not switch the branch. I rebooted my VM, and then all was well - no more hanging. :-)
我在一个文件上打开了 Textpad,我认为它的锁定导致了这个(与提到 Sublime Text 的积极索引锁定文件的 spinx 相同)。即使我关闭了 Textpad,我仍然无法切换分支。我重新启动了我的虚拟机,然后一切都很好 - 不再挂起。:-)