Search code examples
gitgit-stash

How can I stash my changes and go back to my last check-in in Git?


The story goes like so:

I branched my repo to try and do some changes to the way my wcf stuff works. I checked in my changes to my new branch a day ago when everything was dandy before I started to get a bit weird with wcf. I then started trying out some stuff that hasn't really worked out, though I think i'm on the right track.

Now I don't have time to keep trying this so I'd like to go back to my last checkin but I don't want to lose this stuff forever. Is this possible?


Solution

  • You can stash it (using git stash) in which case your working directory will be reset to your last checkin (ie. to your HEAD).

    Or you can branch your current branch to a new branch, and then commit your changes there. I prefer to use branches to stashes when possible, I see stashes as a much more temporary/transient tool.