如何将我的git恢复到原始HEAD?

时间:2014-12-16 21:54:10

标签: git

我试图回滚到之前的提交,显然我搞砸了。 所以我需要恢复。

幸运的是,我做了一个藏匿处;但在应用它后,我收到以下错误:

error: Your local changes to the following files would be overwritten by merge:
    Bliss.storyboard
    Bliss2.xcodeproj/project.pbxproj
    Bliss2/(3.0)DiscoveryViewController.swift
    Bliss2/(3.6)Contribute.swift
    Bliss2/(3.7)CameraContribute.swift
    Bliss2/Environment.swift
Please, commit your changes or stash them before you can merge.
Aborting

所以我再次藏起来。这是我的藏匿处:

$~/workarea/bliss/Bliss2:git stash list
stash@{0}: WIP on RicBranch: e3cb317 Revert "Linked up BlissThoughts & hidden toggle for (3.6) TextView" Temp go back and see old 
stash@{1}: WIP on RicBranch: 40e664a Creation of (3.10) DiscoveryUploadViewController.

所以我尝试了这个并得到了同样的错误:

$~/workarea/bliss/Bliss2:git stash apply #1
error: Your local changes to the following files would be overwritten by merge:
    Bliss.storyboard
    Bliss2.xcodeproj/project.pbxproj
    Bliss2/(3.0)DiscoveryViewController.swift
    Bliss2/(3.6)Contribute.swift
    Bliss2/(3.7)CameraContribute.swift
    Bliss2/Environment.swift
Please, commit your changes or stash them before you can merge.
Aborting
$~/workarea/bliss/Bliss2:git commit -m 'Committed garbage'
On branch RicBranch
Changes not staged for commit:
    deleted:    ../(3.6)TableViewCell.xib
    modified:   ../Bliss.storyboard
    modified:   ../Bliss2.xcodeproj/project.pbxproj
    modified:   (3.0)DiscoveryViewController.swift
    modified:   (3.6)Contribute.swift
    modified:   (3.7)CameraContribute.swift
    modified:   Environment.swift

no changes added to commit
$~/workarea/bliss/Bliss2:git stash apply #1
error: Your local changes to the following files would be overwritten by merge:
    Bliss.storyboard
    Bliss2.xcodeproj/project.pbxproj
    Bliss2/(3.0)DiscoveryViewController.swift
    Bliss2/(3.6)Contribute.swift
    Bliss2/(3.7)CameraContribute.swift
    Bliss2/Environment.swift
Please, commit your changes or stash them before you can merge.
Aborting
$~/workarea/bliss/Bliss2:

这里是我所在位置的快照。我想回滚到RicBranch':

enter image description here

我试图回到“干净”的状态。 commit:(3.10)提交。
但是Git一直说我必须做另一次提交/存储。

我想要做的就是在发生所有这些混乱之前回滚到我之前的HEAD。

如何弹出原始HEAD或应用2nd Stash(版本3.10)?

2 个答案:

答案 0 :(得分:0)

环境:Xcode 6.1

当我搞砸了我的git时,我正在一个新的分支机构工作。
如果我失败了,我想我可以很容易地回到原来的分支。但由于腐败,我无法启动Xcode。

我不得不去命令行,也使用gitX。这都是修复它的问题......所有的存储库都在那里。

所以我最终使用了:

git reset --hard HEAD

现在我回到了我开始的地方。

顺便说一句:我还是想在没有搞砸应用程序的情况下偷看之前的提交。

答案 1 :(得分:0)

对于未来,也许你可以使用给你这样的gil log /或git reflog

yourHash HEAD@{0}: rebase finished: returning to refs/heads/dev
yourHash HEAD@{1}: commit : some commit
yourHash HEAD@{2}: rebase finished: returning to refs/heads/dev
...

如果要检索特定状态,可以执行git reset --hard yourHash

希望这个帮助