git/list[1] front-page[2] threads[3] people[4] search[5] about
 

file deletion in index lost after checkout -b

From
JXJing Xue <jingxue@digizenstudio.com>
Date
Sep 1, 2008, 03:44 UTC
Message-ID
<20080901034414.GR6619@jabba.hq.digizenstudio.com>
In Git 1.6.0 the following sequence:

$ git init $ echo 'abcdefgh' >1.txt $ echo '12345678' >2.txt $ git add 1.txt 2.txt $ git commit -m 'init' $ git rm 2.txt $ echo 'qwertyuiop' >>1.txt $ git add 1.txt $ echo 'asdfghjkl;' >3.txt $ git add 3.txt $ git status $ git checkout -b foo $ git status

produces this output:
Initialized empty Git repository in /home/jingxue/workspace/sandboxes/test.git/.git/
Created initial commit 918f3c6: init
 2 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 1.txt
 create mode 100644 2.txt
rm '2.txt'
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   1.txt
#       deleted:    2.txt
#       new file:   3.txt
#
M       1.txt
A       3.txt
Switched to a new branch "foo"
# On branch foo
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   1.txt
#       new file:   3.txt
#

The deletion of 2.txt appears lost during 'checkout -b foo', while the modification and addition were both brought over. Is it a bug?

Cheers.
-- 
Jing Xue
Next: Junio C Hamano
Message 1 of 6 in “file deletion in index lost after checkout -b”
  1. Jing XueSep 1, 2008
  2. Junio C HamanoSep 5, 2008
  3. Jing XueSep 6, 2008
  4. Junio C HamanoSep 6, 2008
  5. Re* file deletion in index lost after checkout -bJunio C Hamano, Sep 8, 2008
  6. Jing XueSep 9, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.