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

stage/commit issue when checking out a branch

From
PMPeter MacMillan <peterm@metavera.com>
Date
May 12, 2009, 16:01 UTC
Message-ID
<d96d20670905120901qa4c0353xc50160f880e17a21@mail.gmail.com>
Hello,

I've run into a problem where staging changes, checking out a different branch, and then commiting results in an empty commit.

Here is a simplified reproduction of the problem:
currently using 1.6.3, verified that it works correctly in git version 1.6.1.3.
New repo:

$ mkdir bug $ cd bug $ git init Initialized empty Git repository in /home/peterm/bug/.git/

New file:
$ echo "Hello" > FILE
$ git add FILE
$ git commit -m "V1"
[master (root-commit) 5aeea22] V1
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 FILE
Simple change:

$ echo "Hello, world." > FILE $ git add FILE

Move to a different branch:

$ git checkout -b branch M FILE Switched to a new branch 'branch' $ git status # On branch branch # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: FILE #

Oh, still on the stage. Great. Commit!
$ git commit -m "V2"
[branch 818175e] V2
$ git show HEAD
commit 818175efc55d2e23871541c5caa2fe771c825b73
Author: Peter MacMillan <peterm@metavera.com>
Date:   Tue May 12 11:38:02 2009 -0400
    V2
$ git status
# On branch branch
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   FILE
#

Guh? A few of us at the office have hit this and it used to work. The only way to commit the stage is to reset to HEAD, re-add and then commit.

Thanks for your help,
Peter MacMillan <peterm@metavera.com>

Application Developer, Metavera Solutions Inc. 502-2221 Yonge Street, Toronto, ON, M4S 2B4 416-598-9300 x 27

Next: Junio C Hamano
Message 1 of 3 in “stage/commit issue when checking out a branch”
  1. Peter MacMillanMay 12, 2009
  2. Junio C HamanoMay 12, 2009
  3. Revert "checkout branch: prime cache-tree fully"Junio C Hamano, May 12, 2009

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.