Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Checkout hangs indefinitely with git bash. How to solve?

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.

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.

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.!

Has anyone come across this, and if so, how did you go about solving this issue?

like image 346
jamessct Avatar asked Feb 13 '17 15:02

jamessct


People also ask

How do I force checkout in git bash?

Force a Checkout You can pass the -f or --force option with the git checkout command to force Git to switch branches, even if you have un-staged changes (in other words, the index of the working tree differs from HEAD ). Basically, it can be used to throw away local changes.

How do you stop a command execution in git bash?

If you are using the git cli directly, pressing q in the keyboard will also do the job for you. Show activity on this post. ctrl + c is the most used task killing command for command based working windows.

Why does git status hang?

If you are using Windows, check to see if some Windows process has some file or files in that repository locked. If so, your git command will wait for that other process to release the lock, before proceeding. If that other process never lets go, Git never proceeds.


2 Answers

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. :-)

like image 159
Bosco Avatar answered Oct 15 '22 15:10

Bosco


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.

like image 28
spiralx Avatar answered Oct 15 '22 14:10

spiralx