gitx 如何让我的“分离头"提交回主 [英] gitx How do I get my 'Detached HEAD' commits back into master

查看:15
本文介绍了gitx 如何让我的“分离头"提交回主的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 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 如何让我的“分离头"提交回主的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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