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

Re: [PATCH] git-rm: don't remove newly added file without -f

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 26, 2007, 21:17 UTC
Message-ID
<Pine.LNX.4.63.0703262314090.4045@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7v1wjbwvzl.fsf@assigned-by-dhcp.cox.net>
Hi,
On Mon, 26 Mar 2007, Junio C Hamano wrote:
Show 16 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Given this set of commands:
> >
> >   $ echo "newly added file" >new
> >   $ git add new
> >   $ git rm new
> >
> > the file "new" was previously removed from the working
> > directory and the index. Because it was not in HEAD, it is
> > available only by searching for unreachable objects.
> 
> I am not sure if this is a problem, as the user asked it to be
> removed.  It somehow feels to me that the change (I am not
> convinced your patch should be called a "fix" rather than a
> "behaviour change") would cause more confusion.
I agree it would add to confusion.

It is well established that "git rm" also removes the file _in the working directory_.

If you don't want the file to be deleted, but only the corresponding entry _in the index_, use "git rm --cached".

Ciao, Dscho

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 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.