1

I'm using git bash and I needed to check out some previous commits to see if a bug was in those commits (I only have a single branch). I had some uncommitted changes I was working on and I checked out my latest commit using git checkout <commit id>. I then returned from detached head state by using git checkout master, however the uncommitted changes were gone.

First of all I thought git prevented you from checking out a previous commit if you had uncommitted changes? Secondly, are those uncommitted changes I made lost?

PCR
  • 265
  • 1
  • 5
  • 14
  • This is strange, checking out master should have failed if you have uncommitted changes. Furthermore, checking out commit from the branch doesn't remove uncommitted changes (at least for me on git 2.7.4). Are you sure nothing else happened? – BVengerov Sep 18 '16 at 05:42
  • I'm quite sure. Those were the only git commands I ran, and I did find it peculiar that it let me check out a previous commit without committing the unsaved changes. – PCR Sep 18 '16 at 06:17
  • What is your git version? Can you reproduce it? Is there any chance that the changes were indeed unsaved rather than uncommitted? Can you show the relevant command history? – MasterAM Sep 18 '16 at 11:11
  • @MasterAM I can reproduce that checkout works when there are uncommitted changes, but when going back, the changes are still there. (using `git version 2.8.1.windows.1`). – Christoph Sep 18 '16 at 17:23
  • Perhaps a [duplicate](http://stackoverflow.com/questions/22053757/git-checkout-another-branch-when-there-are-uncommitted-changes-on-the-current)? – Christoph Sep 18 '16 at 17:28

0 Answers0