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

[Bug] git-status shows bad instructions prior to first commit

From
RKRhodes, Kate <masukomi@gmail.com>
Date
Feb 12, 2008, 00:59 UTC
Message-ID
<F1B5775C-1C11-4C30-B72E-9EB4076613A5@gmail.com>
git-status incorrectly reports that you should

# Changes to be committed: # (use "git reset HEAD <file>..." to unstage) #

when working on the Initial commit.

To reproduce mkdir foo cd foo touch a.txt git init git add a.txt git status

The problem is, obviously, that calling git reset HEAD a.txt will result in fatal: Failed to resolve 'HEAD' as a valid ref.

Why this is important: New users are Going to accidentally add files they didn't mean to in their first trials with Git. Providing instructions guaranteed to error when people are just getting started with it will give git a bad image and hurt adoption. Also, just about every time I've added a sizable project to a new version control system I've accidentally added a file before the first commit, usually something that should be added to the ignore file, but still, I think this isn't some random isolated problem that people never encounter.

While we're at it, can someone please explain to me how to remove a file from the index prior to the first commit? I'm stumped.

-masukomi
Next: Junio C Hamano
Message 1 of 4 in “[Bug] git-status shows bad instructions prior to first commit”
  1. Rhodes, KateFeb 12, 2008
  2. Junio C HamanoFeb 12, 2008
  3. Jeff KingFeb 12, 2008
  4. Junio C HamanoFeb 13, 2008

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.