git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] "git checkout BRANCH -- FILE" deletes staged commits
@ 2019-11-19 17:10 Tasnad Kernetzky
  2019-11-22  3:14 ` Brandon McCaig
  0 siblings, 1 reply; 4+ messages in thread
From: Tasnad Kernetzky @ 2019-11-19 17:10 UTC (permalink / raw)
  To: git


[-- Attachment #1.1: Type: text/plain, Size: 1142 bytes --]

Hi,

I suppose I found a bug in git version 2.24.0. Please consider the small
shell script to reproduce.

Best,

Tasnad


#!/bin/bash
# init repo, create master branch
git init
echo 'master' > tst
git add tst
git ci -m 'master'

# create branch "B" where tst contains the line from master plus a line "B"
git checkout -b B
echo 'B' >> tst
git commit -am 'B'

# back in master: stage a change
git checkout master
echo 'master_dirty' >> tst
git add tst
echo '*** tst should contain [master, master_dirty]: ***'
cat tst
echo '-------------'

# checkout copies over contents from B -> I guess the bug is here,
changes are not detected
git checkout B -- tst
git status
echo '-> this seems to be wrong, change is not detected'

# if we now go to B and back to master, we loose staged changes
echo '*** tst should contain [master, B]: ***'
cat tst
echo '-------------'
git checkout B
echo '*** tst should contain [master, B]: ***'
cat tst
echo '-------------'
git checkout master
echo '*** tst should contain [master, B]: ***'
cat tst
echo '-------------'
echo '-> wrong / staged changes lost!?'



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2019-11-26 22:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` Fwd: " Tasnad Kernetzky
2019-11-26 22:07     ` Brandon McCaig

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).