3

My design (html/css) changed/gone awry after I popped back stashed repo.

Here is what I did. In order to temporary try out something,

  1. I did a git stash
  2. Then, checked onto an earlier commit git checkout fd3243d but did not make any changes.
  3. Immediately did git stash pop.

Now, to my horror (that sinking feeling), when I refreshed design in browser it went totally awry and on the very top it reads

<<<<<<< Updated upstream ======= >>>>>>> Stashed changes <<<<<<< Updated upstream ======= >>>>>>> Stashed changes

Can anybuddy help me get back to the state pre first step i.e. before I did a git stash?

I don't have any backup's and last commit was done quite a while back. I have a feeling that this can be done but don't know how since I am very new to git.

Can anybuddy help? Thanks dk

dkjain
  • 831
  • 1
  • 9
  • 36
  • 1
    Sounds sticky, and I wish I could help you now, but I'm afraid you might have to manually resolve the conflicts or ditch your changes. Next time use `git stash apply` so you retain your changes on the stack, then you can `git stash drop` when you're sure you're done with them. This would allow you to easily `git reset --hard` – Jeff Puckett Jul 14 '16 at 12:44
  • 1
    Good news: It appears that doing `git stash pop` does _not_ change the stash in case conflicts occur, q.v. [here](http://stackoverflow.com/questions/22207256/undo-git-stash-pop-that-results-in-merge-conflict). Check your stash to see if you work is still there. If so, just checkout to the right place and pop again my friend. – Tim Biegeleisen Jul 14 '16 at 16:16
  • Would you mind commenting or accepting the provided answer? – AnimiVulpis Aug 01 '16 at 12:10
  • 1
    Hi, I have deleted that directory because I had a backup. However, after learning more abt `git`, I am 98% sure that your solution will quite likely solve that problem I was facing, so I will mark that as correct. Thanks for taking the time to help. – dkjain Aug 03 '16 at 08:34

1 Answers1

1

Assuming you were on the master branch before follow these steps:

  • Check that your stashed changes are still in the stash. Git won't pop (remove) a stash that could not be applied cleanly

    git stash list
    

    For more detailed checks try:

    git stash show stash@{<the-number-behind-your-stash>}
    
  • This should be the case (otherwise an edit to this answer will explain how to rescue your changes)

  • git reset --hard back to master (or any other branch that your stash was created from). You can find out from which branch (or commit) your stash was created by looking at the output from git stash list again

  • git stash pop should now apply your changes cleanly and your changes are back

AnimiVulpis
  • 2,670
  • 1
  • 19
  • 27