126

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?

Regis Portalez
  • 4,489
  • 1
  • 28
  • 39
Patrick Jackson
  • 16,090
  • 21
  • 78
  • 137
  • 5
    Something like - "strace -efile -f git push" may reveal more about where the hangup is. – Eric Johnson Apr 05 '13 at 21:39
  • Has anything changed on the remote repo? Such as having a long-running post-receive hook installed? – Gavin Apr 06 '13 at 13:00
  • 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? – Patrick Jackson Apr 06 '13 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. – qwerty9967 Apr 06 '13 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) – Fabio Oct 22 '18 at 00:44
  • The only thing that you need to do is waiting. – pusswzy Dec 18 '18 at 02:23

23 Answers23

165

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.

Patrick Jackson
  • 16,090
  • 21
  • 78
  • 137
  • 26
    well 2kb file is not large in my case .... internet connection is awesome still hangs arghhhh – Rami Dabain Sep 24 '13 at 14:32
  • 2
    This was helpful. Good thing I didn't interrupt it :P – Glogo Nov 15 '13 at 00:06
  • 2
    I'm having a similar issue, but the Network indicator in Windows 8's Task Manager says 0% activity... – Pieter May 28 '14 at 14:09
  • 2
    @Pieter - I get exactly the same - no apparent network activity (even though it was quite a big push) but then it finished OK – Andy Feb 24 '17 at 08:25
  • 4
    It's a pretty bad designed interface, after "finishing" keep doing things with no user feedback. – Hernán Eche Apr 25 '20 at 16:04
  • 1
    What worked for me was switching to a VPN. Must have been some routing problem with part of the traffic to Github. – Joshua P. Swanson Oct 02 '20 at 05:35
  • @Patrick It seems like you had 27.64 MB of files and yet you say you had to wait a while. I have 132.24 MB, I think 10 minutes passed, still waiting... – Niraj Niroula Oct 17 '20 at 17:00
  • 6.78 MiB and it's been like 45 minutes already... :( – Graciela Carrillo Jan 19 '22 at 20:07
  • 1
    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](https://stackoverflow.com/a/68711337/1676393) fixed my problem. – postylem Mar 15 '22 at 00:52
  • I downvoted this answer because the answer below about increasing the http.postBuffer size is the real answer most people are probably looking for. – topherPedersen May 19 '22 at 15:45
113

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

2540625
  • 10,156
  • 8
  • 46
  • 53
Faiz Ahmad Dae
  • 1,260
  • 1
  • 9
  • 12
  • 11
    Insane. No other solution worked for me. I wonder why it just hangs instead of printing an error message after waiting for hours... – Ercksen Oct 10 '21 at 18:25
  • Why 157286400 bytes (150 MiB)? – 2540625 Nov 01 '21 at 01:43
  • 16
    `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. – aroth Dec 16 '21 at 04:46
  • 7
    How is this not the accepted answer? This solved it. – Graciela Carrillo Jan 19 '22 at 20:11
  • 3
    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 – Stoyan Jan 25 '22 at 14:58
  • 2
    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... – Renetik Feb 01 '22 at 01:23
  • 1
    This was the solution for me as well. I anticipated something with the filesize, because I was uploading an MP4 file with a few MBs just before. But I stuck as I got no error messages. Neither from VSCODE nor at the CLI. – chiefenne Feb 06 '22 at 17:17
  • 2
    Fixed my problem. thank you – Ozgur Sar Apr 22 '22 at 17:05
  • 2
    This is the right answer! Please upvote if you see this to push it to the top spot. The top voted answer probably isn't right in most cases. – topherPedersen May 19 '22 at 15:45
13

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.

Alim Özdemir
  • 2,166
  • 1
  • 22
  • 33
  • Yep, this was totally the issue on our local group-shared git repo. Weird that git didn't give any errors or warnings. – Ogre Psalm33 May 22 '19 at 15:08
  • ... did this a thousand times before ... still needed to read your answer to double check the perms INSIDE the dir, thanks! – moritz Jul 23 '19 at 20:06
11

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.

buhtz
  • 8,057
  • 11
  • 59
  • 115
pal4life
  • 2,950
  • 4
  • 32
  • 56
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.

gordey4doronin
  • 662
  • 7
  • 8
2

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

cherrysoft
  • 1,120
  • 8
  • 17
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.

1

The problem is that the upload file is big.

Either you wait it out or go to your project folder and delete all the libraries which you could find in the target folder if using maven. Then do the push and it will happen quickly.

Anyways, the library folders need not be stored in git, it's just a waste of git space unless and until they are not available in the maven repositories and you really need to store them

codemania23
  • 915
  • 10
  • 19
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.

dzimney
  • 555
  • 1
  • 5
  • 14
1

Adding another local commit and retrying push worked for me.

sandeepkunkunuru
  • 5,680
  • 5
  • 31
  • 35
1

Use this command:

git remote add origin <url>
git push -f origin main
buhtz
  • 8,057
  • 11
  • 59
  • 115
Two
  • 358
  • 3
  • 15
0

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.

Nikita R.
  • 6,687
  • 2
  • 49
  • 59
0

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

Augustin
  • 2,294
  • 20
  • 23
0

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

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

Pipo
  • 4,013
  • 36
  • 39
0

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.

jmarks
  • 625
  • 6
  • 16
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.

float13
  • 31
  • 6
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.

0

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

David P
  • 1
  • 1
  • 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](/help/how-to-answer). – Community Mar 19 '22 at 03:35
-1

I got this recently when trying to push ~40 files around 2MB in total. git push --verbose revealed no errors, but would just hang after Total <...> was written to the terminal.

I reissued a new PAT via GitHub and the push went through as expected.

Reed
  • 1,305
  • 17
  • 32
-1

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!

Isaac Tait
  • 173
  • 1
  • 9
-1

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

-3

If you've waited long enough and the problem still persists, try this:

1 - with CTRL+C (command +C) stop the process.

2- Make a very small and ineffective change to any file. (for git system to detect a new file as modified).

3- Follow the git add and git commit steps and push your change.

git add modified_file
git commit -m "new commit message"

4- run git push command and you will see it works without any problem

git push