如何恢复'脱离头部状态'的提交? [英] How to recover commit from 'detached head state'?

查看:131
本文介绍了如何恢复'脱离头部状态'的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了更新后的另一个分支,然后做了一些更改,切换回主Git,现在变更消失了!我可以让他们回来吗?终端基本上是:

  $ git commit 
[detached HEAD 7c09e17]修正了一些东西
文件改变了,插入(+),删除( - )
$ git push master
致命:'master'看起来不是git存储库
致命:远程端意外挂起
$ git checkout master
前面的HEAD位置是7c09e17 ...修正了一些东西
转换到分支'master'
$ git merge theother /目录

解决方案

pre> git merge 7c09e17

应该足够了。 git 通常会告诉您提交ID,如果您观看终端。


I checked out another branch with updates then made a few changes, switched back to the main git and now the changes disappeared! Can I get them back? the terminal was basically:

$ git commit
[detached HEAD 7c09e17] Fixed some stuff
  files changed, insertions(+), deletions(-)
$ git push master
fatal: 'master' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git checkout master
Previous HEAD position was 7c09e17... Fixed some stuff
Switched to branch 'master'
$ git merge theother/directory

解决方案

Assuming you're still on master:

git merge 7c09e17

should be enough. git is usually good about telling you the commit IDs, if you watch the terminal.

这篇关于如何恢复'脱离头部状态'的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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