git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Instructions concerning detached head lead to lost local changes
@ 2007-02-01 22:51 Carl Worth
  2007-02-01 23:49 ` Linus Torvalds
  2007-02-02  1:41 ` Junio C Hamano
  0 siblings, 2 replies; 9+ messages in thread
From: Carl Worth @ 2007-02-01 22:51 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]

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 #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-02-02  7:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-01 22:51 Instructions concerning detached head lead to lost local changes Carl Worth
2007-02-01 23:49 ` Linus Torvalds
2007-02-02  1:41 ` Junio C Hamano
2007-02-02  2:00   ` Carl Worth
2007-02-02  2:06   ` Carl Worth
2007-02-02  2:49   ` Nicolas Pitre
2007-02-02  6:59     ` Theodore Tso
2007-02-02  7:14       ` Nicolas Pitre
2007-02-02  7:44         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).