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?

- 6,066
- 13
- 54
- 95
-
41In the terminal, execute as one statement `GIT_TRACE=true git pull`, and then see if you can see what it is doing when it hangs. – Lasse V. Karlsen May 17 '17 at 17:23
-
1Are you on Windows? If so, and if it is hanging during the `git merge` step, do you have some process running that is holding a lock on some file? Windows has "mandatory locking" in which if process *A* has a file locked, and process *B* (Git) tries to *use* that file, process *B* is paused until *A* releases the lock. If you terminate *B* (i.e., ^C out of Git), ideally it should clean up its `index.lock` file (which doesn't use Windows' mandatory locking, it's just an ordinary file Git uses to coordinate with itself), but apparently it doesn't. – torek May 17 '17 at 17:53
-
In my case, it worked after closing cmder, vscode, and azure data studio. So one of them must've had a lock on a git-related file or something. – JohnnyFun Jun 22 '23 at 16:52
17 Answers
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
.

- 6,018
- 3
- 41
- 44
-
1`git gc --prune=now` did it for me, though it did take about 10-15 minutes to finish. I ran it with `GIT_TRACE=true git gc --prune=now` to verify it was working and not permanently lagging. (`git fsck` lagged for me and didn't seem to help) – skplunkerin Feb 08 '22 at 20:03
I am in Windows, and I solved the hang by closing the Visual Studio before doing the pull.

- 4,510
- 3
- 36
- 44
-
4(On Mac OS X) I had Visual Studio Code opened and it hung on `git pull`. Closed it. Did `git pull` again and VS Code launched and opened a commit message for the `merge` that was needed because of the `git pull`. Entered a message, saved, closed the window and all was well. – Jheasly Nov 01 '17 at 01:33
-
2I had issues with my network which was blocking the ssh connections, when I read your answer I realized that my problem can be other thing than what I was expecting to be. – allexiusw Aug 23 '21 at 17:41
Check SSH_AUTH_SOCK isn't pointing at a stale ssh-agent endpoint. Unset it (unset SSH_AUTH_SOCK
) to test.

- 41,404
- 5
- 117
- 189
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.

- 1,726
- 16
- 32
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".

- 4,041
- 22
- 39
-
Thank you, I just switched to main branch to update and noticed it asking for a password. – Neha Agarwal Oct 23 '22 at 16:53
-
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

- 321
- 4
- 15
-
I had to run ```bash sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 ``` on Pop_OS! for a GitLab repo too, worked fine for GitHub, very weird. – Brian Di Palma Apr 01 '22 at 19:28
In my case, the problem was solved by switching ssh to use IPv4.
To do that, put AddressFamily inet
string into ~/.ssh/config
file.

- 1,563
- 16
- 16
-
-
-
git pull & git checkout hangs with bitbucket with ipv6 address, that config removed the problem – user85155 Apr 27 '23 at 08:03
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.

- 1,277
- 1
- 11
- 23
-
Thanks so much for this! They've had this issue since 2018 and it still exists. Unbelievable! – rbennell Jan 01 '22 at 16:29
I updated git scm 2.32.0 to 2.33.1 version and problem with hanging fetch, push, pull was resolved

- 479
- 5
- 15
-
thanks! it's working,I just download the latest version of git that solved my problem! – Bub Mar 22 '22 at 06:23
For me, port 22 (SSH port) was blocked by the university I was visiting (affecting the eduroam network). Instead, I started using port 443 (HTTPS port). To diagnose if port 22 is blocked you may compare if ssh -T -p 22 git@ssh.github.com
blocks and ssh -T -p 443 git@ssh.github.com
gives a message.
For a single repo, my solution was to add an alternative remote I called origin443
git remote add origin443 ssh://git@ssh.github.com:443/[USERNAME]/[REPO-NAME].git
To fix this problem regardless of repository you can update/add the ssh Github entry in your ~/.ssh/config
to always use 443 for Github. Use:
Host github.com
Hostname ssh.github.com
Port 443
User git
For more information see SSH over HTTPS on Github docs

- 123
- 7
-
I don't think that this is relevant as the question clearly mentions that donwloading refs work. – Baju Jun 15 '23 at 12:02
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.

- 2,125
- 18
- 27
In my case, the 'git pull' hangs in the vscode terminal(zsh), which cannot display the password prompt. Using another shell (login via putty) other than in vscode to solve this problem

- 11
- 1
-
you can debug git pull from here: https://stackoverflow.com/questions/6178401/how-can-i-debug-git-git-shell-related-problems – user13161721 Aug 24 '22 at 05:11
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

- 639
- 6
- 10
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))

- 743
- 10
- 20
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

- 27,856
- 27
- 95
- 103

- 47
- 6
-
1Can you add some detail about why you believe this will fix the issue? Thanks! – Bek Jan 08 '22 at 15:49
-
1Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 08 '22 at 18:05
When going through all the resources/domains under my ~/.git/config
I started to test/ping/telnet all domains, one of them - simply didn't answer, its IP was changed. that caused the entire git pull
to hang...

- 7,298
- 1
- 57
- 65
I had the same problem. I tried all the solutions described here in the other answers, and nothing worked. Then I noticed that I'm only having this problem with one repo, and other repos were working fine.
I double checked that there is no "index.lock" file for the repo that was having the problem. Then I just deleted the entire folder and re-cloned the repo. Problem solved.

- 2,994
- 5
- 31
- 34