【发布时间】:2013-11-22 19:04:09
【问题描述】:
我可以在硬重置后恢复以下提交吗?
步骤:
1) $ (master) // ....made a bunch of changes to files thinking I was working on a branch
2) $ git checkout -b 001-branch // copy changes to a branch to work with
3) $ (001-branch) // make some more changes to files
4) $ (001-branch) git commit -a -m 'added and changed stuff'
// at this point I was just going to pull force master to latest then rebase my 001-branch off of original master (not the stuff I had modified)
5) $ (001-branch) git checkout master
6) $ (master) git reset --hard HEAD
7) $ (master) git pull
8) $ (master) git checkout 001-branch // go back to my branch and rebase my changes
9) $ (001-branch) // oops...my changes were all kiboshed and I don't see the commit I did per git lg
有什么办法可以摆脱这种混乱来恢复我的更改?
【问题讨论】:
-
几个问题:(1)第4步的提交真的成功了吗? (2) 你真的在第 8 步做了一个变基吗? (3)“所有kiboshed”是什么意思?你有没有看到第 4 步中的提交,它是否以某种方式被破坏了,或者它只是丢失了? (4) 你在 001-branch 的
git reflog中看到你的提交了吗? reflog 是让自己摆脱这种事情的常用方法。 -
这能回答你的问题吗? Recover from git reset --hard?
标签: git