169

I'm trying to git push -u origin master And it just hangs at

Writing objects: 99% (219/220), 12.65 MiB | 97 KiB/s 

The 12.65 part shifts around. When I exit the process and run it again, it resumes at 99% but never finishes, same as before.

It's never pushed successfully. This is the initial commit.

4
  • Where do you want to push to? Are you using SSH or some other protocol? Commented Jul 31, 2011 at 3:01
  • 37
    Would setting the http.postbuffer help? stackoverflow.com/questions/6842687/… Commented Jul 31, 2011 at 6:55
  • 4
    VonC's comment is too easy to overlook. It works for me. Commented Mar 10, 2014 at 13:36
  • 1
    Unbelievable. That did it for me, too. And it's 2018 now. And it's SSH, not HTTP. And the whole repo is like 15MB. And the "remote" server is localhost. Stop romanticizing Git, folks, please! ;) Commented Mar 2, 2018 at 23:51

11 Answers 11

398

I followed VonC's advice:

git config --global http.postBuffer 524288000 

For future references, based on comments:

500 MB: 524288000 (as posted in the original answer) 1 GB: 1048576000 2 GB: 2097152000 (anything higher is rejected as 'out of range') 
Sign up to request clarification or add additional context in comments.

7 Comments

on the client or on the server?
On the client @wutzebaer
@HugoForte Increasing the buffer seemed to resolve my hanging writing of files, but my git push never completed (hung after Writing objects: 100%) -- previously it was hanging at 25% so this clearly helped. However, I was still getting "weird" behavior. I restarted my system and this seemed to resolve things...FYI...if anyone is still hitting issues after increasing their buffer, restarting my system helped in my situation (old school solution none the less but a fresh restart really helped).
@twknab even after restarting my system, the push is not completing. Do you have any solution for this?
@HugoForte I tried but after write finish it stucks
|
47

This was happening because of huge, unignored file in the repo directory. Whoops.

EDIT

The hang was because the file was taking a long time to upload. The file wasn't supposed to have been included in the push.

EDIT

While it's true that a huge file could be the reason behind this issue, if you can't ignore the file in question or just have to push it then follow this answer.

7 Comments

Yes, your fix was to remove the problem. For the sake of other people who actually need to push a large file, @hugo-forte's answer solves the problem. You don't have to, I just thought it would help more people - in the spirit of SO.
The question is not "How can I commit, then push a huge file?". It's "My git push is neverending. Why?" If you aren't expecting the push to take forever, then you probably (like me) didn't mean to commit that huge file.
@mattalxndr When the accepted answer has 1/8 the votes, you should probably change it.
@mattalxndr Neither answer is perfect. One identifies the cause, and the other offers a solution. The ideal answer would identify the cause, explain why it has the given result, and offer the two alternative solutions. IMO, out of the current options, Hugo Forte's answer is superior because it will solve the problem regardless of whether you meant to push the file or not. It's not ignoring the people who made the same mistake you did; it fixes the problem for them just as much as anyone else, but leaves it to them to remove a file if they didn't intend to push it.
"Hugo Forte's answer is superior because it will solve the problem regardless of whether you meant to push the file or not." I see your point there. Changed to @Hugo's answer.
|
12

I had the same problem with (writing objects %16) stuck then fatal. I solved this by saving the current changes and clone a new repository, then copy the modified files into it.

Eg. Assume current repository is A, then all you need to do is:

  1. mv A B
  2. git clone A
  3. mv B/* A/
  4. rm -rf B

Then commit and push and it all worked fine. It recognized the moved files as modified :)

1 Comment

You were experiencing a different symptom. Mine didn't have any fatal errors.
6

In my case, I was using a git folder with bad rights stored on the same drive as a repo, but it could be the same with ssh even if you use an authorized login user.

Check then if you have correct rights to write on the distant repo.

Example:

Init local and distant repo

git init /tmp/src git init --bare /tmp/dst cd /tmp/src 

Adding remote repo to origin

src > git remote add dest /tmp/dst 

Simulating problem

src > chmod -R 555 /tmp/dst 

Adding fake file and pushing it

src > touch a && git add a && git commit -m 'demo' src > git push --set-upstream dest master src > git push Counting objects: 3, done. Writing objects: 99% (2/3), 202 bytes | 0 bytes/s. 

Git hangs

Solution

src > chmod -R 775 /tmp/dst 

2 Comments

Please consider adding a few more exemplary details to your answer, thanks.
Sorry. Is it better ?
3

In my situation it was the size of the file. By adding an .gitignore file with the required extensions I was able to ignore most of the unwanted files to be pushed.

Comments

3

For Iranian

Unfortunately, due to severe disruptions in the Internet in Iran, the only method that worked for me was using a DNS changer that came from the Ministry of Cut of Communications.

Comments

2

In my case I was having slow internet upload speed and the file I wanted to push was big, the trick is to use git LFS (large file storage) that is much more patient to upload big files, you can find a git LFS tutorial here

Comments

1

In my case, I was trying to push without completing my company's rules. I learnt later that we should start our commit messages with "MOBIL-XXXX" where XXXX is the number developers are assigned in Jira (another tool we use to track development process) by analists.

Make sure to check if your company has a similar constraining rule.

Comments

1

I was having the same issue on Windows 10 machine, the writing objects was hanging, but in a little different situation.

The problem I was having was only when I was trying to add new files to the repository. If I update files which are already existing in the repository everyting was working fine and it doesn't really matter if the file size was big or not. Mostly I was trying to add new scripts.

I tried every other solution found in the internet but nothing worked in my case and the last thing which I tried actually worked. It seems that it was because of some Windows permissions for the specific drive and folder which prevents the app's from writing in those specific folders or update the files even when I am logged in with an admin account and was running the app as admin. So this command:

attrib -r +s D:\foldername 

fixed the issue for me.

Just posting it here, maybe someone have the same issue as mine.

1 Comment

Not only windows! I had the same problem when admin had forgot to give me any permissions to put my files to remote repo. Why no errors?
1

If you run all of these git commands, it will increase the buffer time and allow the process to complete:

git config --global http.postBuffer 500M git config --global http.maxRequestBuffer 100M git config --global core.compression 0 

I tried all of the other solutions, but I could not get them to work. This solution works for very large git repos.

Comments

0

git clean -f -n solves my issue. There are many untracked files not detected. But be careful because this will remove files in your directory

4 Comments

Specifically which files will it remove?
git clean gets rid of any uncommitted files. The -f flag forces the command to run, and the -n makes it a dry run and tells you which files will be removed. So... You'll see which files get deleted. So actually, @Jazimov, you're undoing the -n flag by having the -f flag ahead of it. git-scm.com/book/id/v2/…
@unixcorn right, been years since I'm answering questions and comments
I had no uncommited files but there were large files went with a commit and then deleted with next commit. It was hanging, and after running this cmd it pushed right away. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.