Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does git pull hang?

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?

like image 228
user3685285 Avatar asked May 17 '17 17:05

user3685285


People also ask

Why git pull is not working?

This might be happening because of some conflict files present in your repository . And you was still trying to check in files . So After that what happen , it will check in your local repository not in master repository . So u was not able to pull or check in anythings in master(head) repository .

Why is git push taking so long?

If you are starting a new project from a clone, (from the CLI without a fork) when you push to a blank remote you are pushing the entire history of the project you just cloned. This is going to take some time. If you just need the clone as it stands and you don't want the history, delete the .

Should you git pull every day?

Pull frequently You should endeavor to keep your local machine as close to the remote repository as possible. The way to do that is to pull all the changes on the remote server to your local copy. You can do this as often as you like, and should do it frequently — at least once a day if not more.

What does git pull actually do?

The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.


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

like image 179
Akif Avatar answered Oct 07 '22 23:10

Akif


I am in Windows, and I solved the hang by closing the Visual Studio before doing the pull.

like image 9
Zac Avatar answered Oct 07 '22 22:10

Zac


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.

like image 9
zachaysan Avatar answered Oct 07 '22 22:10

zachaysan