git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tasnad Kernetzky <tasnadk@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: git@vger.kernel.org
Subject: Fwd: [BUG] "git checkout BRANCH -- FILE" deletes staged commits
Date: Mon, 25 Nov 2019 21:18:05 +0100	[thread overview]
Message-ID: <b1898690-667b-f413-7ac1-08ef733e7fa5@gmail.com> (raw)
In-Reply-To: <aaa2b05a-4c0c-8194-6488-f1b770f3b852@gmail.com>

Hi Brandon,

Thanks for your deep inspection!

I know that the checkout command I was using was supposed to overwrite
the file, but I didn't know that it automatically stages changes. So I
agree, that step makes sense and I should have rtfm.

My only suggestion for the docs would be to add "staging" or so to the
sentence "When a |<tree-ish>| is given, the paths that match the
|<pathspec>| are updated both in the index and in the working tree.".
However, I think it's also clear enough as-is, so I don't see much room
for improvement there.

Please find my last comment in-line.


Best,

Tasnad


On 22.11.19 04:14, Brandon McCaig wrote:
[...]
> When you switch back to branch B the state of the tst file is the
> same as it exists in the branch B. There is no conflict here so
> it succeeds, and once it does you no longer have any changes made
> to tst because the version in your index and working tree matches
> the version in the HEAD commit.
>
> git status at this point would report nothing (assuming no other
> files are modified).

This is the point I actually considered as a bug. There are staged
changes and usually git doesn't let me switch away from a branch in such
cases.

Although I don't lose data, I do lose the newest state of the master
branch, if I'm not cautious and remember that I copied over changed from
"B".

I would prefere at least a warning :) 


  parent reply	other threads:[~2019-11-25 20:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 17:10 [BUG] "git checkout BRANCH -- FILE" deletes staged commits Tasnad Kernetzky
2019-11-22  3:14 ` Brandon McCaig
     [not found]   ` <aaa2b05a-4c0c-8194-6488-f1b770f3b852@gmail.com>
2019-11-25 20:18     ` Tasnad Kernetzky [this message]
2019-11-26 22:07     ` Brandon McCaig

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=b1898690-667b-f413-7ac1-08ef733e7fa5@gmail.com \
    --to=tasnadk@gmail.com \
    --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).