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

git commit not committing, confused

From
Sseanh <snhmnd@gmail.com>
Date
Feb 25, 2011, 19:02 UTC
Message-ID
<20110225190235.GB15815@kisimul>
How did this happen?

I have a git repo containing a LOG.txt file. I made some changes to this file and committed them. Actually, I called this script which did so:

	#!/bin/sh -e
	# Append timestamped one-liners to a file and commit the file to git.
	logdir=~/txt
	logfile=LOG.txt
	cd "$logdir"
	if [ $# = 0 ]; then
		# No command-line arguments, just print out the last entry.
		tail -n 1 $logfile
	else
		entry="[`date`] [`hostname`] $*"
		echo $entry >> $logfile
		git commit $logfile -m "$logfile: $*"
		git push
		tail -n 1 $logfile
	fi

The script executes (and shows output from git) with no errors. `git log` shows the commit, `git log -p` shows the changes committed to the LOG.txt file.

However, `git log LOG.txt` does _not_ show the commit. `git status` shows LOG.txt as modified and unstaged. `git diff LOG.txt` shows a diff of the changes to LOG.txt, the same changes so that show up in `git log -P`. After running `git add LOG.txt` again, `git status` still shows LOG.txt as modified and unstaged! `git commit LOG.txt` reports 'no changes added to commit'.

So this doesn't make sense. I don't know what happened or how. git's index seems to have got into a mess. If I clone the repo then cd into the clone and run git status it shows LOG.txt as modified and unstaged, even though this is a brand new fresh clone!

Message 1 of 1 in “git commit not committing, confused”
  1. seanhFeb 25, 2011

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.