Thread (8 messages) flat view 8 messages, 6 authors, 2016-08-11

Re: On removing files and "git-rm is pointless"

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-08-11 19:43:59


On Mon, 4 Dec 2006, Junio C Hamano wrote:
FWIW, I too am in favor of the proposed fix to "git rm" as Linus
outlined.
Note that somebody (sorry, forget who) correctly pointed out that in order 
to be "safe", the file that you "rm" has to match not only the index, but 
it should match the HEAD tree too.

If it matches both the index and the HEAD tree, a "git rm filename" is 
totally safe, since you can always get it back by just doing a

	git checkout HEAD filename

so the "git rm" really didn't lose any info, and as such, we can _happily_ 
remove the working tree copy without any concern at all.

If it doesn't match HEAD, we can't get it back as easily, so maybe that's 
the case when we want to have "git rm -f filename".

(And obviously, for all the normal reasons, if the index or HEAD doesn't 
match, the error message should be helpful and also explicitly mention the 
"-f" flag. Somehing like

	file 'x' does not match HEAD or has been staged for changes.
	Will not remove. Use '-f' to force removal.

("has been staged for changes" is just a long way of saying "index". See? 
I _can_ learn.)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help