339

My git push is hanging after appearing to complete the push. I am going git push

Counting objects: 51, done. Delta compression using up to 2 threads. Compressing objects: 100% (47/47), done. Writing objects: 100% (47/47), 27.64 MiB | 6.47 MiB/s, done. Total 47 (delta 4), reused 0 (delta 0) 

It hangs here and I have to control-c to get back to command line. I have made several commits in the past with this project with no issues. I have tried other repos on my machine and they work fine. What is going on here?

6
  • 8
    Something like - "strace -efile -f git push" may reveal more about where the hangup is. Commented Apr 5, 2013 at 21:39
  • Has anything changed on the remote repo? Such as having a long-running post-receive hook installed? Commented Apr 6, 2013 at 13:00
  • 1
    No. I'm using bitbucket, so I don't have access to everything. I'm starting to think it is just a big transfer that is taking a long time . Is there any kind of progress indicator when pushing? Commented Apr 6, 2013 at 20:32
  • Has something gone wrong with the permissions on the repo that you're pushing to, or is that location out of disk space. I've seen both problems. Also a git gc may help. Commented Apr 6, 2013 at 23:14
  • 2
    Had exactly the same problem: in my case the git user on the server didn't own the bare repo - root owned it (had forgotten the -R in the chown) Commented Oct 22, 2018 at 0:44

41 Answers 41

586

https://git-scm.com/docs/git-config#Documentation/git-config.txt-httppostBuffer

http.postBuffer

Maximum size in bytes of the buffer used by smart HTTP transports when POSTing data to the remote system. For requests larger than this buffer size, HTTP/1.1 and Transfer-Encoding: chunked is used to avoid creating a massive pack file locally. Default is 1 MiB, which is sufficient for most requests.

Note that raising this limit is only effective for disabling chunked transfer encoding and therefore should be used only where the remote server or a proxy only supports HTTP/1.0 or is noncompliant with the HTTP standard. Raising this is not, in general, an effective solution for most push problems, but can increase memory consumption significantly since the entire buffer is allocated even for small pushes.

Resolution

  1. Increase the Git buffer size to the largest individual file size of your repo

  2. git config --global http.postBuffer 157286400

  3. Refer to the resolution of Git push fails - client intended to send too large chunked body for ngnix reverse proxy configuration. Increase this parameter to the largest individual file size of your repo.

  4. Bypass the outbound proxy as explained on Can't clone or pull due to a git outbound proxy

Sign up to request clarification or add additional context in comments.

18 Comments

Insane. No other solution worked for me. I wonder why it just hangs instead of printing an error message after waiting for hours...
Why 157286400 bytes (150 MiB)?
git config --global http.postBuffer 157286400 was ther answer. Probably would also have been fine with one less 0 on the end of that number.
it did worked for me as well. I was merging two repositories together, and the repo i was pushing was 500 mb big. The push was hanging, i updated the postBuffer, ran it again and it worked and pushed instantly
Looks like this works.. Fun how so many people here answer abut network activity and so on not realising how many people here have issues where it hangs for hours without any network activity and I can repeat and repeat and then miraculously it pass then again multiple times hangs.. so very bad issue no error nothing git has so flawed ui and everyone use it .. strange...
|
240

This turned out to be no problem at all. I simply had to wait until the upload was complete. I had added several large files and there is not a progress indicator. Maybe someone else will find this helpful.

12 Comments

well 2kb file is not large in my case .... internet connection is awesome still hangs arghhhh
This was helpful. Good thing I didn't interrupt it :P
I'm having a similar issue, but the Network indicator in Windows 8's Task Manager says 0% activity...
It's a pretty bad designed interface, after "finishing" keep doing things with no user feedback.
I have a push which is 27 MB and it hung for 24 hours already (I didn't even notice it hadn't worked, and came back to my computer to see the git push command was still hanging). Was very confused. Increasing the size of http.postBuffer as in Faiz Ahmad Dae's answer below fixed my problem.
|
147

Try:

git gc

I had it hang at the same spot but with very small files, so waiting was not the answer. The solution was a git gc (garbage collection) to recalculate the deltas in the repo.

7 Comments

When I git pull --all I had same problem but I could fix it by git gc and then git pull --all again thanks.
I removed a bunch of larger files at one time, and I think that was causing the issue on mine hanging up. This is the solution that worked for me. Mine was hanging up after it finished processing (i.e., the Total line). So, I just terminated, then ran git gc, then ran git push and it worked fine.
git gc made it, just pushed after that and everything went fine
Nice! This fixed it for me when the only working solution in the past was changing the postBuffer. Thanks!
This worked for me. Finally! Thank you, this was driving me insane; the smallest of commits would cause this hanging problem. I'm skeptical that it will work again when this problem shows up again only because I have tried other things in the past that worked a few times and then stopped solving this problem after some time.
|
21

It only worked for me in the case when I did git push -u origin main, when I just simply used git push for bit bucket, it did not push through.

3 Comments

using git push -f origin main would print like these fatal: the remote end hung up unexpectedly Everything up-to-date
This is so true for bitbucket repo.
Wow. I did not expect this to work. I'm pushing to Google Cloud Source Repos.
14

It can be (as the accepted answer suggests) just a moment to wait, but in the majority of cases it is linked to permissions on the remote. While mostly a non-issue on public git services such as GitHub, Gitlab or Bitbucket, self-hosted remotes might have a special user, or a group for access.

And on new bare repositories it doesn't suffice to change the folder, but instead needs to be recursive because of .git-Folder inside.

2 Comments

Yep, this was totally the issue on our local group-shared git repo. Weird that git didn't give any errors or warnings.
... did this a thousand times before ... still needed to read your answer to double check the perms INSIDE the dir, thanks!
14

Adding another local commit and retrying push worked for me.

3 Comments

Changing the postBuffer didn't get me across the line, but this did. Can't say I understand the underlying problem at all, but thankyou!
This worked for me! Thank you
This worked once or twice for me, but seemed to be more luck than actually somehow solving the problem.
10

For me it worked when I switched to bash instead of zsh terminal.

4 Comments

There should not be any difference. Your zsh install is probably misconfigured, or you have a misbehaving plugin.
Same for me, change to bash terminal fixed it
Same for me. What might be the issue?
Same, how should I troubleshoot this?
8

After waiting for two plus hours my git push was still stuck. So, I had to reset back before the commit where I had accidentally uploaded a 3.1mb photo (that I am guessing was the culprit for the freeze).

I found a much more amicable solution that @aroth shared above git config --global http.postBuffer 157286400 was the answer.

I just opened a new iTerm window ran the above command and then ran git push while the terminal in VSCode was still hung up. Then I ctrl c closed the terminal session in VSCode and I was back in business.

Thank you @aroth!

1 Comment

worked like a dream for me!
5

Use this command:

git remote add origin <url> git push -f origin main 

1 Comment

Thanks @buhtz for editing—making my solution upto date.
5

I hit this exact symptom while pushing a specific branch to an Azure Devops Git repo, and tried most of the advice in the thread with no luck.

I opened an internal azure DevOps support ticket, which was immediately resolved as a problem with the Git client itself, and they suggested running:

git config --global http.version HTTP/1.1 

... this immediately unblocked me (current default is now 2.0 I guess) and is worth trying if you hit this symptom.

3 Comments

This fixed the issue for me on AWS codebuild platform for pushing updated tags
This fixed my issue like a charm
This is also a cool solution. Thanks
4

I've had the same issue with pushing commit to GitHub. In my case, the issue was in a branch. I've tried to push the local branch with a relatively large commit without having a remote branch git push --set-upstream origin <your branch name>. I've managed to fix this issue by creating a branch on GitHub and then pushing the commit.

Comments

3

This problem is solved for me after I use brew install git.

I use macOS 13.0 with M1 chip. It is my new laptop that I only used it for a few days and mainly with GitHub Desktop to work with GitHub. I have the same hanging problem after git push many files via terminal. I tried git gc but it doesn't help me much.

3 Comments

For the benefit of the novice developers, brew is homebrew which can be installed from here
Just for the sake of completeness... the solution for me was also to switch from Apple git to official git. The difference is that I use MacPorts, so the solution is sudo port install git. I also had to create a new shell, to pick up the new version.
This worked for me on mac m1 pro after trying all other solutions.
3

Tuning off the VPN helped me...

Comments

2

Waiting until the upload finished doesn't work for me. I pushed not very big file, but waited long enough, still hanged.

What helped for me is updating from msysgit 1.9.5 to git-for-windows 2.6.2.

Comments

2

Permissions can also be cause of this in the case of a bare repo on a remote machine.

Comments

2

In my case, changing remote url from "https" to "ssh" solved the problem.

Comments

2

The previous answers did not work for me:

  • increase the buffer, e.g.: git config --global http.postBuffer 157286400
  • clean: git gc

What worked for me

I solved it by pushing every single commit of a Pull Request, instead the whole one.

tl;dr:

git push remote commit:branch

details:

  • show the commits, e.g. git log
  • use one commit hash, e.g. 894cf22
  • push commit, e.g. git push origin 894cf22:dev/task_feature1
  • repeat

further details:

Comments

1

See if you have staged, but not committed changes. (git status)

If so, commit (or unstage) those and then try to push. Worked for me.

1 Comment

Yes! This worked for me. In MacOS with zsh. MacOS version 12.5.1, git version 2.32.1
1

In my case it was caused by a problem with msysgit 1.9.5. Downgrading to msysgit 1.9.4 solved the problem.

Comments

1

Just wanted to add this in case it helps anyone. I had the same problem, and the issue was that the git user didn't have permission to write to the files, only to read from them.

Comments

1

This issue can be caused by issues with your SSH agent.

I recently ran into this issue because I changed my default shell from zsh to bash. I'd originally set up my ssh keys using zsh, and so they were not available by default to bash, using chsh -s /bin/bash.

To fix, you'll need to add your ssh key(s) to the SSH authentication agent using the same shell script (bash, sh, zsh, etc) you're using to perform your git commands:

eval `ssh-agent` ssh-add ~/.ssh/some_key_rsa 

You'll need to enter the passphrase for the key in order to add it. To store the passphrase to your user keychain so you don't need to enter it every time the key is used, add the key with the -K option to the ssh-add command.

ssh-add -K ~/.ssh/some_key_rsa 

Note the uppercase K as using a lowercase is a different command option.

Comments

1

I ran into this same problem while pushing to GitHub. I found that a subset of the files being pushed wasn't being accepted.

I found this out by breaking my large commit into smaller commits (as described in this SO question: Break a previous commit into multiple commits), and then finding success with most of the smaller pieces.

The problem piece contains image files and I'm still sorting out which particular file (or files) triggers the problem.

1 Comment

I had this same issue on Azure DevOps. My initial commit wouldn't push, so I broke it up into multiple separate commits and pushed them individually. Annoying, but it worked.
1

I had same issue. It's fixed by running this command.

git config --global sendpack.sideband false 

2 Comments

Why? What does the command do?
It disable git sendpack: git-scm.com/docs/git-send-pack
1

tl;dr

Creating a new remote repository worked.

Pointless, long story.

The problem has only ever happened when I make edits to a particular 6MB .svg file.

I put Git on verbose mode and pushed and left it for hours and the remote hung up.

I suspect the issue only happens for certain remotes; I'm using Google Cloud Source Repositories.

Update

I can confirm it is caused by Inkspace SVG files. I removed one SVG file from the repo but left another in, assuming the one I took out was corrupt or too large.

I made edits to the small SVG file and then committed and pushed and it hung on push. I closed VS Code, pushed again from the terminal and it worked.

Git + Google Cloud Source Repos + Inkscape SVG files cause these hangs for me.

Comments

0

In my case, the remote had a full disk. Removing some files on the remote promptly fixed the issue.

Comments

0

Checkout the user rights that git is using!

In my case I tried through ssh and the used system user was unable to write into the git bare repository...

Here is how you can debug your ssh connection

Comments

0

I wanted to second @Fabio's comment to the original post - that solved it for me.

I'm running my own ad hoc local git server on Raspberry Pi. I forgot to chown the new bare repo, and pushing the first commit from a remote PC would just hang indefinitely.

This fixed it (running chown as root or with sudo):

cd /srv/git chown git:git -R <repo_name>.git 

Replacing <repo_name> with the name of your repo.

Comments

0

I had the same issue and it turns out I had an older version (that i deleted but had the same name) of the repo connected to Heroku. When i disconnected it, it completed the push.

Comments

0

In my case the Git hosting platform GitHub had issues with their servers so check your provider status too.

1 Comment

Your 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.
0

For me, I had installed Bitdefender and that was causing the issue. Uninstalled it and it was all fine

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.