git status shows fatal: bad object HEAD

前端 未结 14 1263
醉酒成梦
醉酒成梦 2020-12-09 00:44

I have a problem with git on Windows Azure. Git status shows - \"fatal: bad object HEAD\" and I tried running:

 git fsck --full
 git gc

But

相关标签:
14条回答
  • 2020-12-09 01:07

    I solved this by copying the branch data (with the errors) to my apple laptop local git folder.

    Somehow in the terminal and when running: git status, tells me more specific data where the error occurs. If you look under the errors, hopefully you see a list of folders with error. In my case GIT showed the folder which was responsible for the error. Deleting that folder and commiting the branche, I succeeded. git status was working again the other devices updating by git pull; everything working again on every machine.

    Hopefully this will work for you also.

    0 讨论(0)
  • 2020-12-09 01:08

    I had a similar problem and what worked for me was to make a new clone from my original repository

    0 讨论(0)
  • 2020-12-09 01:10

    Running

    git remote set-head origin --auto
    

    followed by

    git gc
    
    0 讨论(0)
  • 2020-12-09 01:12

    try this : worked for me rm -rf .git

    You can use mv instead of rm if you don't want to loose your stashed commits

    then copy .git from other clone

    cp <pathofotherrepository>/.git . -r

    then do

    git init

    this should solve your problem , ALL THE BEST

    0 讨论(0)
  • 2020-12-09 01:13

    In my case the error came out of nowhere, but didn't let me push to the remote branch.

    git fetch origin
    

    And that solved it.

    I agree this may not solve the issue for everyone, but before trying a more complex approach give it a shot at this one, nothing to loose.

    0 讨论(0)
  • 2020-12-09 01:15

    This happened to me on a old simple project without branches. I made a lot of changes and when I was done, I couldn't commit. Nothing above worked so I ended up with:

    1. Copied all the code with my latest changes to a Backup-folder.
    2. Git clone to download the latest working code along with the working .git folder.
    3. Copied my code with latest changes from the backup and replaced the cloned code (not the .git folder).
    4. git add and commit works again and I have all my recent changes.
    0 讨论(0)
提交回复
热议问题