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

Re: Git commit behaving strangely

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 21, 2010, 03:06 UTC
Message-ID
<20100721030608.GA25992@burratino>
In-Reply-To
<4C465B34.2040407@zqureshi.in>
Hi Zeeshan,
Zeeshan Qureshi wrote:
> 3. then i added 1 new line to both closing.txt and file.txt
> 4. i added the file closing.txt to the staging are by running 'git
> add closing.txt'
> 5. now i ran 'git checkout' (by mistake)
[...]
Show 5 quoted lines
> 7. Now when i run 'git commit -m "closing again"', the change is not
> committed even though i get a new commit id.
> 
> The output of 'git log -p' is this (as you can clearly see, there
> are new commits but no change has been recorded)

Strange. I tried to reproduce this but I got different results (the new commit includes in a change to closing.txt). What am I doing wrong?

 git init repo
 cd repo
 echo 'hello world' >file.txt
 git add .
 git commit -m 'Initial version of repo, a test repository'
 echo closing >closing.txt
 git add closing.txt
 git commit -m 'Goodbye, all'
 echo 'hi!' >>file.txt
 echo 'again?' >>closing.txt
 git add closing.txt
 git checkout
 git diff --cached
 git commit -m 'closing again'
 git log -p
Previous: Zeeshan QureshiNext: Zeeshan Qureshi
Message 2 of 5 in “Git commit behaving strangely”
  1. Zeeshan QureshiJul 21, 2010
  2. Jonathan NiederJul 21, 2010
  3. Zeeshan QureshiJul 21, 2010
  4. Zeeshan QureshiJul 22, 2010
  5. Jonathan NiederJul 22, 2010

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.