-2

I attempted to rollback to a previous commit and apparently I screwed up. So I need to recover.

Fortunately I did a stash; but after applying it I got the following error:

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

So I stashed again. Here's my stashes:

$~/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.

So I tried this and got the same error:

$~/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:

Here's a snapshot of where I'm at. I want to rollback to 'RicBranch':

enter image description here

I'm trying to rollback to the 'clean' commit: the (3.10) commit.
But Git keeps saying I must do another commit/stash.

All I want to do is to rollback to my previous HEAD, before all this mess occurred.

How to I do a pop to original HEAD or apply the 2nd Stash (version 3.10)?

Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105
  • First - what does your `git status` show? Also, are you trying to go back to a specific stash entry, or a commit on another branch? – Makoto Dec 16 '14 at 21:54
  • This link might be helpful: http://stackoverflow.com/questions/15164300, since it looks very related. – Tay Rotby Dec 16 '14 at 21:58
  • `git reset --hard ` will return you to a particular commit, unless you've already pushed your changes. (It will do that, then, too, but things get complicated on the remote side, esp. if others work with your repository too) – Phillip Dec 16 '14 at 21:59

2 Answers2

0

Environment: Xcode 6.1

I was working within a new branch at the time I screwed up and corrupted my git.
I thought I could easily return to my original branch should I fail. But I couldn't launch Xcode due to the corruption.

I had to go to the command line and also use gitX. It's all a matter of fixing it...all the repository was there.

So I ended up using:

git reset --hard HEAD

Now I'm back to where I began.

BTW: I would still like to peek at a previous commit without screwing up the app.

Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105
0

For the future maybe you could use the gil log / or git reflog that gave you something like that :

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
...

Then you can do git reset --hard yourHash if you want to retrieve a particular state

Hope this help

Chilipote
  • 1,037
  • 1
  • 8
  • 30