git-rm isn't the inverse action of git-add
- From
- Christian Jaeger <christian@jaeger.mine.nu>
- Date
- Jul 2, 2007, 18:09 UTC
- Message-ID
- <46893F61.5060401@jaeger.mine.nu>
Hello
I'm coming from cogito. There you can run:
cg-add $file ; cg-rm $file
and everything is as before; it adds the file to the directory index/cache, and just removes it again from the latter.
Whereas with git,
git-add $file; git-rm $file
is giving the error
error: '..file..' has changes staged in the index (hint: try -f)
And sure enough, git rm -f $file will remove the file from the index, but also unlink it from the directory. (Ok, I did remember that cogito's -f option is unlinking the file, so I was cautious and didn't try it on an important file, but still...)
Turns out that
git rm -f --cached $file
will do the same action as cg-rm $file.
Why so complicated? Why not just make git-rm without options behave like cg-rm? (Or at the very least, I'd change the hint to say "try -f --cached".)
Christian.