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

[PATCH] Fix 'git commit -a' in a newly initialized repository

From
Fredrik Kuivinen <frekui@gmail.com>
Date
Feb 22, 2007, 20:28 UTC
Message-ID
<20070222202812.8882.44375.stgit@c165>
With current git:

$ git init $ git commit -a cp: cannot stat `.git/index': No such file or directory

Output a nice error message instead.
Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
---
 git-commit.sh |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index ec506d9..476f4f1 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -318,6 +318,10 @@ esac
 
 case "$all,$also" in
 t,)
+	if test ! -f "$THIS_INDEX"
+	then
+		die 'nothing to commit (use "git add file1 file2" to include for commit)'
+	fi
 	save_index &&
 	(
 		cd_to_toplevel &&
Next: Johannes Schindelin
Message 1 of 9 in “Fix 'git commit -a' in a newly initialized repository”
  1. Fix 'git commit -a' in a newly initialized repositoryFredrik Kuivinen, Feb 22, 2007
  2. Johannes SchindelinFeb 22, 2007
  3. Nicolas PitreFeb 22, 2007
  4. Johannes SchindelinFeb 22, 2007
  5. Nicolas PitreFeb 22, 2007
  6. Johannes SchindelinFeb 22, 2007
  7. Junio C HamanoFeb 22, 2007
  8. Nicolas PitreFeb 23, 2007
  9. Junio C HamanoFeb 23, 2007

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.