Git的/分离的头,让下班回来? [英] Git / detached HEAD, get work back?

查看:119
本文介绍了Git的/分离的头,让下班回来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我什么我还以为是我的分公司做了几十个的提交,然后签出的另一个分支。

I made a dozens of commits on what I thought was my branch, then checked out another branch.

愿意回到我最初的分支,我没有找到我的更新code。看着我的控制台历史记录后,我明白我在分离分公司工作...

Willing to go back to my initial branch, I didn't find my updated code. After looking at my history in console, I understood I worked in a detached branch...

是它在某种程度上可能得到我的独立分支所做的工作?

Is it somehow possible to get the job I've done on the detached branch?

推荐答案

是的。你可以使用引用日志。尝试 git的日志-g HEAD 。这将显示您 HEAD ,即每一个提交了 HEAD 已经指出的,原因为什么它的引用日志更改为提交。你应该能够找到你的命令签出的分支,看看有什么previous犯了。

Yes. You can use the reflog. Try git log -g HEAD. This will show you the reflog for HEAD, i.e. every single commit that HEAD has pointed to, and the reason why it changed to that commit. You should be able to find your command that checked out the branch, and see what the previous commit was.

您也可以使用其他语法来索引到引用日志。如果你只是执行 git的结帐分支,那么 HEAD @ {1} 将参考previous检查退房手续提交(所以你可以 git的结帐HEAD @ {1} 来取回它)。或者,如果您知道11分钟前 HEAD 指着正确的事情,你可以使用 git的结帐HEAD @ {10.minutes.ago}

You can also use other syntax to index into the reflog. If you just performed the git checkout branch, then HEAD@{1} will refer to the previous checked-out commit (so you can git checkout HEAD@{1} to get back to it). Or if you know that 10 minutes ago HEAD was pointing to the right thing, you can use git checkout HEAD@{10.minutes.ago}.

这篇关于Git的/分离的头,让下班回来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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