Why does git pull hang?
GitGit BashGit PullGit Problem Overview
When I do a git pull
, from the git bash, the terminal usually runs the pull, updates my local, and then hangs. I'm not sure if it's waiting for me to do something, but I usually exit out of this with CTRL-C
. After that, I get that an index.lock is preventing me from doing other things to which I have to delete it. Am I misunderstanding how git pull
works?
Git Solutions
Solution 1 - Git
You may need to remove unnecessary git objects such as dangling commits & blobs
:
git fsck && git gc --prune=now
> git-fsck : Verifies the connectivity and validity of the objects in the database
>git-gc : Cleanup unnecessary files and optimize the local repository
You can refer here about dangling commits & blobs
.
Solution 2 - Git
If you are pulling from a linux machine you may want to check this file:
/etc/ssh/ssh_config
To make sure you aren't setting your default SSH port to something other than 22. Some people get confused between that file and:
/etc/ssh/sshd_config
When they're setting up servers to a non-standard SSH port.
Solution 3 - Git
I am in Windows, and I solved the hang by closing the Visual Studio before doing the pull.
Solution 4 - Git
Check SSH_AUTH_SOCK isn't pointing at a stale ssh-agent endpoint. Unset it (unset SSH_AUTH_SOCK
) to test.
Solution 5 - Git
Your ISP might be blocking the traffic. For example, VirginMedia in the UK does something with a proxy for their filters that causes GitHub traffic to hang. I had this issue, and disabling the filter fixed it.
Solution 6 - Git
On Fedora 32, all git commands were hanging for me (only for repos on gitlab), solved with
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
leaving this here in case it helps anyone else
Solution 7 - Git
As someone who does not use VS Code very often, I too thought git was hanging when I ran git pull
. Turns out I was just not very observant. As illustrated in the image below, I was laser focused on the terminal and did not notice the prompt for a username which was the actual cause of the "hang".
Solution 8 - Git
Had same issue, which was related to my ssh client.
This was confirmed trying to connect to a remote ssh server with the '-v' (verbose) option
ssh -v -p PORTNUMBER USERNAME@SERVER
which gave rekey after XXXXXX blocks”
before getting stuck.
apt-get purge
and apt-get install
didn't help, so - before facing the interestign approach here exposed at https://apple.stackexchange.com/a/280800 - I went for an easy reboot, which did the job.
Solution 9 - Git
I updated git scm 2.32.0 to 2.33.1 version and problem with hanging fetch, push, pull was resolved
Solution 10 - Git
My problem was that I had changed my ssh config file and this repository was using a non-existent ssh config.
To check remote config:
git remote -v
To check ssh config:
cat ~/.ssh/config
To fix it, I had to remove remote and add a new one:
git remote add origin
git remote add origin right-ssh-config
Solution 11 - Git
I faced the same issue while using VSCode. I solved it by toggling off and on the GitHub: Git Authentication
setting (in User Settings (UI))
Solution 12 - Git
If you are in Linux, close and reopen the terminal and restart your ssh. Enter the following code in the terminal, and try again.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/putHereYourSSHkey
ssh -T git@github.com
Solution 13 - Git
In my case, the problem was solved by switching ssh to use IPv4.
To do that, put AddressFamily inet
string into ~/.ssh/config
file.