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

Removing files

From
David Kågedal <davidk@lysator.liu.se>
Date
Jan 11, 2007, 20:10 UTC
Message-ID
<87bql5cok3.fsf@morpheus.local>
I'm wondering what the best way to commit the removal of a file is.

Let's assume that I have a file "foo" in my tree, that I have removed from my working tree (e.g. by using patch -E).

git status shows:
  $ git status
  # On branch refs/heads/messages
  # Changed but not added:
  #   (use "git add <file>..." to incrementally add content to commit)
  #
  #       deleted:    foo
Ok, so I try to follow the instructions in the message:
  $ git add foo
  fatal: pathspec 'foo' did not match any files
Ok, so that didn't work.  Let's try rm instead:
  $ git rm foo
  fatal: pathspec 'foo' did not match any files

Hm, something is wrong here. But hey, there's a -f option to rm that claims to prevent the "up-do-date check"

  $ git rm -f foo
  fatal: pathspec 'foo' did not match any files
Finally, I have to resort to using update-index.
  $ git update-index --remove foo
  fatal: pathspec 'foo' did not match any files

Since I believe that the idea is to move to an interface where you use e.g. "git add" instead of explicitly mentioning the index, I think this is bad.

What could be the correct command for this situation.  Some suggestions:
  $ git add foo
  $ git add --remove foo
  $ git rm foo
  $ git rm -f foo
-- 
David Kågedal
Next: Alex Riesen
Message 1 of 15 in “Removing files”
  1. David KågedalJan 11, 2007
  2. Alex RiesenJan 11, 2007
  3. Seth FalconJan 11, 2007
  4. Junio C HamanoJan 11, 2007
  5. Eric WongJan 11, 2007
  6. Junio C HamanoJan 11, 2007
  7. git-status: wording update to deal with deleted files.Junio C Hamano, Jan 11, 2007
  8. Carl WorthJan 11, 2007
  9. Junio C HamanoJan 12, 2007
  10. Carl WorthJan 12, 2007
  11. Jakub NarebskiJan 12, 2007
  12. Jeff KingJan 12, 2007
  13. Juergen RuehleJan 12, 2007
  14. Carl WorthJan 11, 2007
  15. Jeff KingJan 12, 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.