299

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,675
  • 1
  • 29
  • 41
Patrick Jackson
  • 18,766
  • 22
  • 81
  • 141
  • 8
    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
  • 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? – 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

34 Answers34

522

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
  • 11,022
  • 8
  • 52
  • 58
Faiz Ahmad Dae
  • 5,653
  • 2
  • 14
  • 19
  • 35
    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
  • 4
    Why 157286400 bytes (150 MiB)? – 2540625 Nov 01 '21 at 01:43
  • 108
    `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
  • 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
  • 4
    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
  • 1
    `git gc` worked well for me. Source: https://stackoverflow.com/a/71763891/9927977 – Reina Reinhart Aug 17 '22 at 21:02
  • 3
    i have tried `git gc` **git with option -f** and `http.postBuffer 157286400` still not work :( – Yogi Arif Widodo Aug 19 '22 at 07:07
  • 2
    @aroth Thanks for sharing git config --global http.postBuffer 157286400 works for me – Balogun Ridwan Ridbay Aug 30 '22 at 11:52
  • 2
    Only steps 1 & 2 under _Resolution_ were needed for me, which solved the problem! In other words: `git config --global http.postBuffer 10000000`. More detail, of course, is in `git config --help`. – TransferOrbit Sep 16 '22 at 08:11
  • 1
    verbose showed me that "POST git-receive-pack (chunked)" was where it was hanging. This fixed the issue instantly. Thanks :) – Ian Nebbiolo Oct 21 '22 at 10:10
  • 1
    insane, `git config --global http.postBuffer 157286400 ` did not work and I have to double that size to make it work... – eggsloveoats Nov 04 '22 at 00:17
  • please somebody help me i tried http.postBuffer 157286400 but not work – masoud anaraki Mar 04 '23 at 22:27
  • What a legend! Appreciate it. – Galapagos Apr 03 '23 at 08:50
  • I tried with git config --global http.postBuffer 157286400. Result writing objects is now fast, but still a problem getting finished. THen I tried strace -efile -f git push and the result is amazing (for me) [pid 30018] newfstatat(1, "", 0x7ffebbea2520, AT_EMPTY_PATH) = -1 EBADF (Bad file descriptor) [pid 30018] +++ exited with 0 +++ ok, how to go on?? – user2609605 Jun 01 '23 at 06:20
  • Even ChatGPT doesn't know this and it's from before it's training data cutoff date – Hack-R Jul 12 '23 at 09:06
225

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
  • 18,766
  • 22
  • 81
  • 141
  • 44
    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
  • 9
    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
  • 5
    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
  • I think it's more related to the connection itself and doesn't matter to the speed of the internet, I just changed the connection to 4g and worked instantly. – abdallah Nofal Aug 09 '22 at 23:54
  • `git config --global http.postBuffer 157286400` This is the correct answer. Following is where I found it. – Shubham Saroj Sep 22 '22 at 08:59
111

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.

Mat
  • 1,344
  • 1
  • 9
  • 8
  • When I `git pull --all` I had same problem but I could fix it by `git gc` and then `git pull --all ` again thanks. – masaya Sep 23 '22 at 11:22
  • 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. – AndrewGB Sep 25 '22 at 06:56
  • 2
    My saviour ! Thanks everyone and thanks @mat ! – M. Gara Nov 11 '22 at 15:28
  • `git gc` made it, just pushed after that and everything went fine – michelem Nov 28 '22 at 09:31
  • Nice! This fixed it for me when the only working solution in the past was changing the postBuffer. Thanks! – Ash West Dec 22 '22 at 20:15
  • 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. – Ray Jennings May 04 '23 at 23:02
  • I ran this after restarting my VSCode and it worked after a short delay. – C RICH Jul 26 '23 at 21:39
  • tried all other solutions , changing buffer and all that but nothing was working. my whole code folder was 2MB. suddently I ran `git gc` and it worked. my code got pushed on remote. – Jamshaid Tariq Aug 07 '23 at 06:28
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.

buhtz
  • 10,774
  • 18
  • 76
  • 149
pal4life
  • 3,210
  • 5
  • 36
  • 57
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.

Alim Özdemir
  • 2,396
  • 1
  • 24
  • 35
  • 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

Adding another local commit and retrying push worked for me.

sandeepkunkunuru
  • 6,150
  • 5
  • 33
  • 37
  • 2
    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! – Joel Roberts Jul 07 '22 at 04:51
9

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

Mikias
  • 131
  • 2
  • 3
7

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
  • 533
  • 5
  • 12
4

Use this command:

git remote add origin <url>
git push -f origin main
buhtz
  • 10,774
  • 18
  • 76
  • 149
Two
  • 512
  • 4
  • 17
3

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.

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
  • 902
  • 9
  • 8
2

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

cherrysoft
  • 1,165
  • 8
  • 17
2

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.

vissi
  • 2,325
  • 1
  • 19
  • 26
wander
  • 43
  • 6
  • For the benefit of the novice developers, brew is homebrew which can be installed from [here](https://brew.sh/) – Grify Dev Apr 18 '23 at 01:25
  • 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. – Mark Birbeck Jun 03 '23 at 14:16
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.

Nikita R.
  • 7,245
  • 3
  • 51
  • 62
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
  • 913
  • 11
  • 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
  • 565
  • 1
  • 5
  • 15
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.

jmarks
  • 655
  • 6
  • 16
  • 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. – Thomas Higginbotham Jul 31 '23 at 20:39
1

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

git config --global sendpack.sideband false
1

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:

deeagle
  • 61
  • 6
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,444
  • 23
  • 24
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,653
  • 38
  • 47
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
  • 71
  • 1
  • 6
  • 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
0

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

0

I tried all of the answers proposed above, but none worked for me. For some reason, this only happened when I was trying to push to 'master'. When I created and pushed to the 'main' branch, it worked just fine.

ela16
  • 740
  • 1
  • 2
  • 13
0

Updating git on the system should work. I had git installed via brew on OS X. brew upgrade git solved the problem.

Probelm description: git push -u origin main was hanging for me after the git output log 'Total ..., reused ..., pack-reused ...' without giving any informative errors.

  • Hasn’t this already been answered? – Guildenstern May 07 '23 at 18:29
  • I didn't see any update answers. The top voted answers explain that it has to do with pushing large files, which was not the case for me. Also another answer recommended installing git, which also was not the case for me (maybe `brew install` also updates if the package is already installed, but I'm not sure.) – ashkan.mokarian May 09 '23 at 07:59
0

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

Onur Uslu
  • 1,044
  • 1
  • 7
  • 11
0

I did a git pull origin dev, then I could push.

lef7
  • 1
  • 1
0

There was a gif file in the .github folder and github can not process the uploading of that file. When I remove the gif file everything went well.

Mehmet
  • 1,467
  • 1
  • 14
  • 19
0

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.

starball
  • 20,030
  • 7
  • 43
  • 238
-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,515
  • 1
  • 21
  • 38