Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull is very slow... Why?

Note I have studied the git-is-very-very-slow question, but in their case the reason was big binary files - while in my repository there is PHP/JS/HTML/CSS only code (no binaries) and the biggest file in the repository is around 800 KB.

I've changed one file (a few lines), then git add . and git commit -m "msg", then git push origin master.

On some other machine, when I do git pull origin master it downloads a few MiB of data, and it takes more than 2 minutes to calculate the delta and apply changes. Something is terribly wrong here.

I suspect some recent operations may cause this:

recently, I've accidentally added many vendor assets (bower_components assets) when I realized it, I've used git rm to remove them from repository (and ofcourse, git add, git commit and git push to upstream).

That was a few days ago and the problems I have right now started happeing around that time.

I have two questions:

  • Why this is happeing?
  • How can I fix my repository?

Note: I am the only one useing and pushing to this repo.

like image 878
ioleo Avatar asked Feb 26 '14 11:02

ioleo


People also ask

How long does a git pull take?

This can be quite expensive in repositories with many references though: in a real-world repository with around 2.2 million refs, fetching a single commit by its ID takes around 44 seconds. Dominating the loading time is decompression and parsing of the objects which are referenced by commits.

Which is Better git fetch or git pull?

When comparing Git pull vs fetch, Git fetch is a safer alternative because it pulls in all the commits from your remote but doesn't make any changes to your local files. On the other hand, Git pull is faster as you're performing multiple actions in one – a better bang for your buck.

Why is git pushing too long?

One possibility might be that you have large binary file(s) commited in the latest commit. git is not good at working with binary file. If commiting binary files was a mistake, you can refer to following answer for getting rid of binary file in commit.

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 .


2 Answers

I had the same issue. For me this was a IPv4/IPv6 issue. I fixed it forcing SSH to use IPv4.

Set "AddressFamily inet" in /etc/ssh/ssh_config to force IPv4 connection. Then restart ssh client sudo service ssh restart

More info here.

like image 64
JGL Avatar answered Oct 06 '22 01:10

JGL


I have had the same issue when I was dealing with thousands of small files. The thing that fixed it for me was to set the postbuffer in git repo's config

git config http.postBuffer 524288000 

Instead of uploading with 18KB/s it suddenly went the full bandwidth

like image 23
Sander Stad Avatar answered Oct 06 '22 00:10

Sander Stad