1

No git's command is working anymore created a branch, made some commits. Then I made a recursive find and replace as so :

LANG=C find . -type f -name '*.*' -exec sed -i '' s/My\ sentence/My\ sentencevotre/ {} +

which worked properly, but now I can't commit, I can't reset hard, I have a serie of messages when reseting : error: packfile .git/objects/pack/pack-$SHA.pack does not match index ...

and when commiting :

warning: packfile .git/objects/pack/pack-$SHA.pack cannot be accessed .... error: invalid object 100644 $SHA for 'Doxyfile' error: Error building trees

How can I manage this ?

epsilones
  • 11,279
  • 21
  • 61
  • 85
  • Try to undo your changes on .git folder. If this does not work you may crashed your repository irreparable. – Hikaru-Shindo Jan 28 '13 at 15:14
  • @Hikaru-Shindo, it is catastrophic... Do you know how I can find the name files which .git/objects/pack/pack-$SHA.pack are related to ? – epsilones Jan 28 '13 at 15:30
  • No, I'm not really well informed about git's internals. If this did not help you will need to restore from a backup or create a new repiository. If you have set up a remote repository you may clone a new copy - then the loss would not be total. – Hikaru-Shindo Jan 28 '13 at 16:56
  • Do not manually modify files under `.git` unless you really know what you're doing. This sounds like you've destroyed your repository. Hopefully you have a clone of it somewhere that you can recover from. – twalberg Jan 28 '13 at 17:22
  • possible duplicate of [Problems with corrupt git repo](http://stackoverflow.com/questions/14569172/problems-with-corrupt-git-repo) – Chronial Jul 15 '13 at 10:30

2 Answers2

1

Undo your find and replace and try again. Maybe you are lucky enough ... otherwise use your backup.

Be more careful with your .git directory next time.

Argeman
  • 1,345
  • 8
  • 22
  • Do you know how I can find the name files which .git/objects/pack/pack-$SHA.pack are related to ? – epsilones Jan 28 '13 at 15:31
  • No, I'm not an expert with the internals of git. I know that all important data is secured with checksums, so that git won't let you work with inconsistent data (exactly what you are experiencing right now) – Argeman Jan 29 '13 at 08:48
0

It seems that you changes files inside you .git folder, which defines the repository. I don't know any other solution for that than deleting .git folder and recreating a new git repository inside the folder. This shouldn't be a big problem if you have a remote repository like GitHub.

th3falc0n
  • 1,389
  • 1
  • 12
  • 33
  • No I didn't use github fir that... Do you know how I can find the name files which .git/objects/pack/pack-$SHA.pack are related to ? – epsilones Jan 28 '13 at 15:31