[英]git - Recover commits that were deleted with checkout
I was 2 commits ahead of Github. 我比Github提前2次提交。 I did git checkout
and these commits were deleted. 我做了git checkout
,这些提交被删除了。 I tried recover the files in .git folder to a previous version using the Dropbox history. 我尝试使用Dropbox历史记录将.git文件夹中的文件恢复到以前的版本。 I ran git status
and showed that I was again 2 commits ahead, I got happy, commited and pushed to Github only to see that I didn't recover at all. 我运行git status
并显示我再次领先2次提交,我感到高兴,坚定并推向Github只是看到我根本没有康复。
tl;dr : Lost 2 commits with git checkout tl; dr :丢失2次并提交git checkout
Just use git reflog
to recover the commits. 只需使用git reflog
即可恢复提交。
git reflog
运行git reflog
git reset --hard commit_id_before_checkout
to get to a state just before you ran git checkout .
运行git reset --hard commit_id_before_checkout
,使其在运行git checkout .
之前进入一种状态git checkout .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.