[BUG] "git checkout BRANCH -- FILE" deletes staged commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux