Git hangs while writing objects

后端 未结 9 2000
执念已碎
执念已碎 2020-12-12 13:21

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

相关标签:
9条回答
  • 2020-12-12 13:45

    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.

    0 讨论(0)
  • 2020-12-12 13:45

    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

    0 讨论(0)
  • 2020-12-12 13:47

    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')
    
    0 讨论(0)
  • 2020-12-12 13:47

    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 :)

    0 讨论(0)
  • 2020-12-12 13:48

    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

    0 讨论(0)
  • 2020-12-12 13:51

    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
    
    0 讨论(0)
提交回复
热议问题