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

Re: git-rm isn't the inverse action of git-add

From
CJChristian Jaeger <christian@jaeger.mine.nu>
Date
Jul 2, 2007, 20:23 UTC
Message-ID
<46895EA4.5040803@jaeger.mine.nu>
In-Reply-To
<20070702194237.GN7730@nan92-1-81-57-214-146.fbx.proxad.net>
Yann Dirson wrote:
Show 11 quoted lines
> On Mon, Jul 02, 2007 at 08:09:37PM +0200, Christian Jaeger wrote:
>   
>> 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".)
>>     
>
> It is probably a matter of taste.  Personally, I am really upset by
> this behaviour that cvs, cogito, stgit and others share, which forces
> me to issue 2 commands to really delete a file from version control
> and from the filesystem.
>   

It doesn't force you to issue 2 commands: the -f option to cg-rm unlinks the file for you. So you only have to type an additional "-f".

Yes it's probably (partly) a matter of taste: in my bash startup files I have mv aliased to mv -i and rm to rm -i, so that it asks me whether I'm sure to delete or overwrite a file. If I know in advance that I'm sure, I just type "rm -f $file", which then expands to "rm -i -f $file" where the -f overrides the -i. cg-rm -f just fits very well into this scheme (the only difference being that "cg-rm $file" doesn't explicitely ask me whether I also want the file to be unlinked). (BTW note that usually for removing a file I use a "trash" (or shorter alias "tra") command, which moves it to a trash can instead of deleting; so I use "tra $file" by default, and only for big files or when I'm sure I immediately want to delete them, I use rm, and then if the paths are clear I add the -f flag, if not (like globbing involved), I don't add the -f and thus am asked for confirmation.)

If I could alias the git-rm command so that the default action is the reverse of git-add and adding an -f flag removes it from disk, that would be fine for me.

> Do you really need to undo an add more often than you need to remove a
> file from version-control ?  It may be worth, however, to make things
> easier.  Maybe "git add --undo foo" would be a solution ?

This doesn't sound very intuitive to me (and I couldn't fix it with an alias).

I don't per se require undo actions. I just don't understand why git-rm refuses to remove the file from the index, even if I didn't commit it. The index is just an intermediate record of the changes in my understandings, and the rm action would also be intermediate until it's being committed. And a non-committed action being deleted shouldn't need a special confirmation from me, especially not one which is consisting of a combination of two flags (of which one is a destructive one).

Christian.
Previous: Yann DirsonNext: Yann Dirson
Message 3 of 37 in “git-rm isn't the inverse action of git-add”
  1. Christian JaegerJul 2, 2007
  2. Yann DirsonJul 2, 2007
  3. Christian JaegerJul 2, 2007
  4. Yann DirsonJul 2, 2007
  5. Matthieu MoyJul 2, 2007
  6. Johannes SchindelinJul 2, 2007
  7. Matthieu MoyJul 3, 2007
  8. Johannes SchindelinJul 3, 2007
  9. Matthieu MoyJul 3, 2007
  10. Johannes SchindelinJul 3, 2007
  11. Jan HudecJul 4, 2007
  12. Matthieu MoyJul 5, 2007
  13. David KastrupJul 5, 2007
  14. [RFC][PATCH] Re: git-rm isn't the inverse action of git-addMatthieu Moy, Jul 8, 2007
  15. Johannes SchindelinJul 8, 2007
  16. Matthieu MoyJul 8, 2007
  17. Johannes SchindelinJul 8, 2007
  18. Matthieu MoyJul 9, 2007
  19. Matthieu MoyJul 13, 2007
  20. More permissive "git-rm --cached" behavior without -f.Matthieu Moy, Jul 13, 2007
  21. Jeff KingJul 13, 2007
  22. Matthieu MoyJul 13, 2007
  23. Jeff KingJul 14, 2007
  24. Jakub NarebskiJul 14, 2007
  25. Junio C HamanoJul 14, 2007
  26. Junio C HamanoJul 14, 2007
  27. Matthieu MoyJul 14, 2007
  28. Christian JaegerJul 2, 2007
  29. Jeff KingJul 3, 2007
  30. Junio C HamanoJul 3, 2007
  31. Jeff KingJul 3, 2007
  32. Junio C HamanoJul 3, 2007
  33. Jeff KingJul 3, 2007
  34. Junio C HamanoJul 3, 2007
  35. Jakub NarebskiJul 11, 2007
  36. Jan HudecJul 11, 2007
  37. Junio C HamanoJul 11, 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.