Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT fatal: failed to read object

Tags:

git

github

I am a beginner in GIT and now I meet with a big problem. I commit and push some files in another PC and now on my home PC git is broken.

Please look below:

$ git status
fatal: failed to read object f4927c0e01f566faf3ef5cb55f974b524af4449c: Invalid argument


$ git commit -m "test"
fatal: failed to read object feb4df55618847c02cb13d334fdac4a313701aed: Invalid argument

$ git pull
fatal: failed to read object f4927c0e01f566faf3ef5cb55f974b524af4449c: Invalid argument

$ git add .
fatal: failed to read object f4927c0e01f566faf3ef5cb55f974b524af4449c: Invalid argument

and last one:

$ git push
Everything up-to-date

Is it any possibiliti to repair my git?

Best Regards!

EDIT: Just delete .git folder. Change name of project folder Clone from github Add new files from my older folder.

I I could do this because I only added new files without any changes to the code.

like image 933
SerSergious Avatar asked May 29 '17 18:05

SerSergious


1 Answers

First of all the problem, your facing is corrupted git repository. It's something odd that many can face, one of the reason when the laptop or PC power outage can cause.


There are certain steps you can follow which can help you to solve the problem:

STEPS

  1. What you can do is to replace the object in .git / refs / heads / my-working-branch" with ".git / logs / HEAD and submit the successful object.

  2. After step1 your git status -s and other commands to return to normal, you can use gitk or other gui tool or just git log will show you the commits.

  3. Then use the git fsck --full command to see if there will be the same as the title of the error. If you found the problem then you need to delete the problem in .git / objects /" .

  4. Then repeat the step 3, until there is no error with the title, to this Git repair is complete.

For more information about fixing corrupted or broken GIT repo.

Fixing broken GIT repo.

like image 155
danglingpointer Avatar answered Oct 06 '22 01:10

danglingpointer