2017-07-08 22 views
0

我在我的git 2分支,master和SSL上。
虽然我以为我在主分支,但我实际上已经分离了。我将更改推送到HEAD,然后结帐到SSL分支并合并它。
当我这样做时,我发现承诺给主人的变化在任何分支上都不存在,我看不到它们。
有没有办法恢复丢失的提交?

运行git reflog -n 20在分离HEAD时推送恢复更改

e4a206b [email protected]{0}: checkout: moving from SSL to master 
94e0f8d [email protected]{1}: checkout: moving from master to SSL 
e4a206b [email protected]{2}: checkout: moving from SSL to master 
94e0f8d [email protected]{3}: reset: moving to 94e0f8d 
18aedb9 [email protected]{4}: checkout: moving from master to SSL 
e4a206b [email protected]{5}: checkout: moving from e4a206b20456d004b5ad19bb859e15f481df9b90 to master 
e4a206b [email protected]{6}: checkout: moving from SSL to master^0 
18aedb9 [email protected]{7}: checkout: moving from master to SSL 
e4a206b [email protected]{8}: checkout: moving from e4a206b20456d004b5ad19bb859e15f481df9b90 to master 
e4a206b [email protected]{9}: checkout: moving from master to master^0 
e4a206b [email protected]{10}: checkout: moving from d8b6feee2ae2595872d62ca2b25c01263b3bf74b to master 
d8b6fee [email protected]{11}: merge SSL: Merge made by the 'recursive' strategy. 
94e0f8d [email protected]{12}: commit: Support for os and badge count for ios 
e4a206b [email protected]{13}: checkout: moving from 18aedb908898083d8b9d6941ec59f981950a3846 to master^0 
18aedb9 [email protected]{14}: checkout: moving from bc071caacff35fca304aae97804fd9070d92913f to SSL^0 
bc071ca [email protected]{15}: commit: Added support for sell option 
e4a206b [email protected]{16}: checkout: moving from 18aedb908898083d8b9d6941ec59f981950a3846 to master^0 
18aedb9 [email protected]{17}: checkout: moving from e4a206b20456d004b5ad19bb859e15f481df9b90 to SSL^0 
e4a206b [email protected]{18}: checkout: moving from SSL to master^0 
18aedb9 [email protected]{19}: commit: SSL 

我已经做了硬复位到提交我想,它仍然缺少一个文件(我真的不知道该怎么做)。

+0

当你说“走了”,你想改变麦凯纳t出现在主人面前,但他们出现在你的另一个分支上? – Makoto

+0

请描述这里“逝去”的意思。如果您确实将更改提交给主分支,那么很难失去这些更改。你做过“git reset”吗?你有没有试过检查主人? –

+0

我已经更新了这个问题。 –

回答

1

基于git reflog,它看起来像你运行git reset94e0f8d [email protected]{3}

你应该能够恢复任何通过简单地检查出复位之前提交承诺工作:git checkout [email protected]{4}

最后一个思想:当您收到一个“分离的头”通知,对于一些有益的指导运行git status

您处于'分离状态'状态。您可以环视,制作 实验性更改并提交它们,并且您可以放弃您在此状态下进行的任何提交 而不影响任何分支,方法是执行 另一个结帐。

如果你想创建一个新的分支保留你创建提交,您可以 再次使用-b与checkout命令这样做(现在或以后)。 例子:

git的结帐-b现在新的分支名

头以81f96ab ......有些犯味精

+0

这就是我所做的。谢谢。 –