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

Removing a newly added file

From
SBSanti Béjar <sbejar@gmail.com>
Date
Mar 26, 2007, 14:59 UTC
Message-ID
<8aa486160703260759v438d445ev82161600d8e8bf02@mail.gmail.com>
Hi *,
  when you try removing a newly added file it success and removes the
file from the working directory. So if you do:

$ echo "newly added file" > new $ git add new $ git rm new

the file "new" is lost, it is not in the index, neither in HEAD. At this moment the only way to recover the file new is searching for unreachable objects. (Am I missing something?)

  I think that the "git rm new" should remove "new" from the index or
should fail, maybe with:

$ git rm new error: 'new' is not in HEAD (hint: try --cached)

  Santi
Next: Jeff King
Message 1 of 7 in “Removing a newly added file”
  1. Santi BéjarMar 26, 2007
  2. git-rm: don't remove newly added file without -fJeff King, Mar 26, 2007
  3. Junio C HamanoMar 26, 2007
  4. Johannes SchindelinMar 26, 2007
  5. Junio C HamanoMar 26, 2007
  6. Jeff KingMar 26, 2007
  7. Junio C HamanoMar 26, 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.