您的位置:首页 > 其它

Recover a file even if it was not committed but it has to have been added when you use git reset head by mistake.

2014-04-17 20:30 716 查看
git init
echo hello >> test.txt
git add test.txt

Now the blob is created but it is referenced by the index so it will no be listed with git fsck until we reset. So we reset...

git reset --hard
git fsck

you will get a dangling blob ce013625030ba8dba906f756967f9e9ca394464a

git show ce01362

will give you the file content "hello" back

To find unreferenced commits I found a tip somewhere suggesting this.

gitk --all $(git log -g --pretty=format:%h)

I have it as a tool in git gui and it is very handy.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐