问题描述
使用 Git X 并且一定在某些事情上笨手笨脚.看起来几天前我创建了一个名为 detached HEAD
的分支,并一直致力于它.我的正常流程是提交给master
,然后将其推送到origin
.但是我不能推送分离的HEAD
.
我的下一站把我搞砸了.我选择了 git checkout master
- 我的 detached HEAD
分支消失了.回到我的项目,这几天我所有的变化都被抹去了.
无论如何我可以恢复这些更改吗?
如果 checkout master
是你做的最后一件事,那么
Using Git X and must have fumbled royally on something. Looks like a few days ago I created a branch called detached HEAD
and have been committing to it. My normal process is to commit to master
and then push that to origin
. But I can't push detached HEAD
.
My next stop screwed me. I selected git checkout master
- and my detached HEAD
branch disappeared. Going back to my project all of my changes in the past few days have been wiped.
Is there anyway I can get those changes back?
If checkout master
was the last thing you did, then the reflog entry HEAD@{1}
will contain your commits (otherwise use git reflog
or git log -p
to find them). Use git merge HEAD@{1}
to fast forward them into master.
EDIT:
As noted in the comments, Git Ready has a great article on this.
git reflog
and git reflog --all
will give you the commit hashes of the mis-placed commits.
Source: http://gitready.com/intermediate/2009/02/09/reflog-your-safety-net.html
这篇关于gitx 如何让我的“分离头"提交回主的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!