Reputation: 9418
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.
Upvotes: 169
Views: 118613
Reputation: 1210
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.
Upvotes: 0
Reputation: 10917
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.
Upvotes: 3
Reputation: 17037
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.
Upvotes: 1
Reputation: 1787
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.
Upvotes: 3
Reputation: 1042
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.
Upvotes: 1
Reputation: 9418
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.
Upvotes: 46
Reputation: 5978
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')
Upvotes: 396
Reputation: 96
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
Upvotes: 6
Reputation: 109
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
Upvotes: 2
Reputation: 2978
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
Upvotes: 1
Reputation: 173
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:
mv A B
git clone A
mv B/* A/
rm -rf B
Then commit and push and it all worked fine. It recognized the moved files as modified :)
Upvotes: 12