8

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.

SerSergious
  • 449
  • 2
  • 5
  • 21

2 Answers2

2

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.

Community
  • 1
  • 1
danglingpointer
  • 4,708
  • 3
  • 24
  • 42
-2

I was getting this:

$ git reset --hard
fatal: failed to read object d4578a93fd08f3b338937e33d75da98d9bf94d58: Input/output error

I used a Dropbox Rewind premium feature that I had on my Dropbox account and it was able to take my entire folder to a previous time when things were working. That obviously included the .git folder and everything in my Android app code/project.

enter image description here

This Dropbox rewind premium feature is awesome. Apparently those broken Git repository issues due to power outages or things like that are more common than I thought (https://git.seveas.net/repairing-and-recovering-broken-git-repositories.html).

Jaime Montoya
  • 6,915
  • 14
  • 67
  • 103