From: "Maris, Rob" <maris.rob@ingenieur.de>
To: git@vger.kernel.org
Subject: git checkout -b following git reset --hard pitfall
Date: Sun, 09 Sep 2012 15:25:48 +0200 [thread overview]
Message-ID: <op.wkdd9andsuzgrs@rob-desktop> (raw)
Normally, when there are modifications in the working tree not yet added
resp. committed, git will refuse to change to another branch.
However, when I create a new branch on the fly, using git checkout -b
<branch>, there is no complaint appearing. After doing so, I executed a
git reset --hard in once case, just thinking that the previous "modified"
branch status was preserved. Of course, this notion is incorrect. But I
realised this after a bit of thinking about it. Actually, the modified
status of git related to both branches after git checkout -b can have
following consequences:
- it is lost definitely when git reset -hard is executed
- if committed, it is committed into the newly created branch
This actually constitutes an asymmetric response (perceived double
deletion vs. single preservation).
I'd wish that git checkout displays *at least* a warning when a "modified"
state is not committed: "warning: Your local changes to the following
files are no longer associated with the previous branch:"
-Rob
git version 1.7.11
next reply other threads:[~2012-09-09 13:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-09 13:25 Maris, Rob [this message]
2012-09-09 13:57 ` git checkout -b following git reset --hard pitfall Andreas Schwab
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=op.wkdd9andsuzgrs@rob-desktop \
--to=maris.rob@ingenieur.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.