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

Git commit behaving strangely

From
ZQZeeshan Qureshi <zeeshan@zqureshi.in>
Date
Jul 21, 2010, 02:28 UTC
Message-ID
<4C465B34.2040407@zqureshi.in>
Hello,

I am new to git and was going through gittutorial-2 when i noticed something weird.

1. I first create a file file.txt with some text and committed it.
2. I create a file called closing.txt with some text and committed it.
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)
6. Now i run 'git diff --cached' (which should show the changes i have 
in the index), the output is this
diff --git a/closing.txt b/closing.txt
index da55920..953ec3a 100644
--- a/closing.txt
+++ b/closing.txt
@@ -1 +1,2 @@
  closing
+again?

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)

commit 7dbe9a272c58decc08f9fd5ce07efd5bf28d89f8
Author: Zeeshan Qureshi <{email}>
Date:   Tue Jul 20 15:36:05 2010 -0400

     closing again

commit 1bfda310eb82e62925b28d62e98097d6fbd61620
Author: Zeeshan Qureshi <{email}>
Date:   Tue Jul 20 15:34:46 2010 -0400

     closing again

commit 3d0e35717bea56adbc7c578b3b17db3657e30040
Author: Zeeshan Qureshi <{email}>
Date:   Tue Jul 20 15:33:40 2010 -0400

     closing

diff --git a/closing.txt b/closing.txt
new file mode 100644
index 0000000..da55920
--- /dev/null
+++ b/closing.txt
@@ -0,0 +1 @@
+closing

commit 2a0a0e4edb1810b6e31b0739bd7736d1360e6d13
Author: Zeeshan Qureshi <{email}>
Date:   Tue Jul 20 15:32:13 2010 -0400

     initial commit

diff --git a/file.txt b/file.txt
new file mode 100644
index 0000000..3b18e51
--- /dev/null
+++ b/file.txt
@@ -0,0 +1 @@
+hello world
-- 
Zeeshan Qureshi
zeeshan@zqureshi.in
Next: Jonathan Nieder
Message 1 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.