Instructions concerning detached head lead to lost local changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So after some recent experiments to explore all this detached head
stuff, I found myself making a change to my code having forgotten I
had some old state checked out.

So, I tried doing something like:

	git checkout master

in order to get where I wanted to be. I was stopped with the warning:

	You are not on any branch and switching to branch 'master'
	may lose your changes.  At this point, you can do one of two things:
	 (1) Decide it is Ok and say 'git checkout -f master';
	 (2) Start a new branch from the current commit, by saying
	     'git checkout -b <branch-name>'.

At this point, I _knew_ that I didn't care about the state I was
leaving, (it was something random that I had done for testing). So I
definitely didn't want to name it with option (2).

I also knew I hadn't done any commits while detached, which is what I
thought the warning was all about. So I wasn't worried about losing
nothing with option (1).

But I found that after "git checkout -f master" I lost the dirty
changes I had made. And I don't see anything in the message above
telling me a better way to get from the state I was in to the state I
wanted.

I don't know if the "-f" always existed for git-checkout, or if it was
added to support this warning. But clearly, the current warning and
suggestion did not help in this case.

And what would have worked great is if the original checkout had just
worked and carried along my dirty changes, (just as would have
happened if I found I had accidentally made changes while on the wrong
branch instead of accidentally making changes while detached).

Can we fix this please?

-Carl

Attachment: pgpHlM4Kq7396.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]