开发者

cant fix bad object HEAD error with git status

开发者 https://www.devze.com 2023-04-04 15:19 出处:网络
My Battery died on my macbook when pushing my repo. Now I cannot run git status $ git status fatal: bad object HEAD

My Battery died on my macbook when pushing my repo. Now I cannot run git status

$ git status
fatal: bad object HEAD
fatal: git status --porcelain failed

I've tried a few suggestions ive found for fixing bad object errors.

$ git fsck --full
dangling tree 65e856976b7aa7c73f15cd71defedb8a3d622a10

I've tried git prune开发者_开发技巧 and git prune-packed

I can still commit, stash, push, it appears to be just affecting git status

Andy ideas?

Thanks


I guess you solved this problem already but i had this to and could fix it simply by run

git pull

This has resulted into a working condition. eventough your files are intact you should backup your local git directory and then run the git pull. after that you should be back in business.

If there are files deleted (it should not happen) you can copy them back over a working checkout and commit them from there.


If your .git/HEAD is corrupted or points to a corrupted object, you can change it manually or by git checkout.


This happened to me when I accidentally added my bin/ folder in an Eclipse Java project.

Using 'git pull' did not work for me.

I fixed it by:

  1. closing Eclipse
  2. rm -rf bin
  3. git rm bin

Then I was able to 'git commit' and continue normally.


This worked for me:

git fetch origin
git reset --hard origin/master


I had the same problem and this worked for me:

git fetch origin
git reset --soft origin/master


Try add all of your modified files with git add filepath/file.ext before the git status.


git checkout -f *branchname* worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消