Git reset failing after find and replace

故事扮演 提交于 2019-12-11 11:01:38

问题


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 ?


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/14564936/git-reset-failing-after-find-and-replace

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!