git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carl Worth <cworth@cworth.org>
To: git@vger.kernel.org
Subject: Instructions concerning detached head lead to lost local changes
Date: Thu, 01 Feb 2007 14:51:04 -0800	[thread overview]
Message-ID: <87mz3xa3vr.wl%cworth@cworth.org> (raw)

[-- 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 --]

             reply	other threads:[~2007-02-01 22:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-01 22:51 Carl Worth [this message]
2007-02-01 23:49 ` Instructions concerning detached head lead to lost local changes 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mz3xa3vr.wl%cworth@cworth.org \
    --to=cworth@cworth.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).