git rebase -i开发HEAD导致Detached Head [英] git rebase -i develop HEAD leads to Detached Head

查看:942
本文介绍了git rebase -i开发HEAD导致Detached Head的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没做很多,但是我认为如果您添加HEAD〜somenumber,它将重新设置基准并仅显示您的最后x次提交.我跑了:

I haven't done this a ton, but I thought that if you add HEAD~somenumber that it will rebase and just show your last x commits. I ran:

▶ gcmsg "added login handling logic"
[user-log-in d66ed88] added login handling logic
 1 file changed, 2 insertions(+), 2 deletions(-)

到目前为止,我一直只是简单地完成git rebase -i开发

Up till now I've always simply done git rebase -i develop

我想尝试一下我在视频中看到的有关挤压的内容,并且我很确定他们使用HEAD〜x表示他们只希望看到最后的x次提交,x是他们指定的任何数字.取而代之的是,我得到的是一个分离的头,就像是wtf!

I thought to try something I saw in a video about squashing, and I am pretty sure they used HEAD~x to say that they want to only see the last x commits, x being whatever number they specify. Instead what I got as a result of this is a detached head and was like wtf!

因此,在这次以上的提交之后,我执行的命令是:

So the command I did after that commit above this time was:

git rebase -i develop HEAD~3 

正因为如此,在重新设置基准期间,它会向我显示我的最后3次提交.当我看到它显示了更多东西时,实际上我没有看到我的前3次提交,我吓坏了,并执行:q退出.当我退出时,它做了一个变基:

thinking that because of this, that during rebase, it'd show me my last 3 commits. When I saw that it showed a lot more and actually I didn't see my last 3 commits I freaked and did a :q to quit. When I quit it did a rebase:

▶ git rebase -i develop HEAD~3      
Successfully rebased and updated detached HEAD.

当我处于git状态时,我不记得以前是否看到过此消息,但现在它显示为分离",这是否有关?

When I do a git status, I don't recall if I've seen this before but now it says detached, is this concerning?

▶ git status
HEAD detached from c452a38
nothing to commit, working tree clean

我在这里很困惑.现在我注意到我所有的更改都消失了.我该如何回过头来:

I'm confused here. Now I noticed all my changes are gone. How do I get the head back to this:

▶ gcmsg "added login handling logic"
[user-log-in d66ed88] added login handling logic
 1 file changed, 2 insertions(+), 2 deletions(-)

我怎样才能使自己恢复到当时的状态,即我所做的承诺?我只想在这里弄清楚,这很疯狂.

How can I get myself back to the state I was at, that commit I did? That's all I want to figure out here, this is nuts.

推荐答案

git checkout [提交时您所在的分支名称]

git checkout [branch name you were in when you did the commit]

就这么简单.我现在很好.

simple as that. I'm all good now.

这篇关于git rebase -i开发HEAD导致Detached Head的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆