硬重置后可以恢复以下提交吗?
脚步:
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
Run Code Online (Sandbox Code Playgroud)
任何摆脱这个烂摊子的方法来恢复我的变化?
Fel*_*peC 15
要查看对001分支所做的所有更改,您可以这样做git reflog 001-branch,但是,你认为你在001分支中做的可能是你做了另一个分支,所以你可能需要查看所有的变化git reflog.
chw*_*arr 14
是否git reflog show打印缺少提交的哈希值?如果是,那么git checkout -b recovery-branch commitId将创建一个指向缺少提交的新分支.然后,您可以根据需要合并.
每当git做一些像改变或倒带分支那样激烈的事情时,它会在reflog中记录.换句话说,仔细检查输出git reflog,它会告诉你你所拥有的所有过渡.然后,您可以使用git show commit_id检查并git checkout commit_id返回.