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

Re: "git rm" seems to do recursive removal even without "-r"

From
Robert P. J. Day <rpjday@crashcourse.ca>
Date
Oct 7, 2017, 21:40 UTC
Message-ID
<alpine.LFD.2.21.1710071740260.16732@localhost.localdomain>
In-Reply-To
<20171007210500.s3s5q53qihtf2s32@thunk.org>
On Sat, 7 Oct 2017, Theodore Ts'o wrote:
Show 39 quoted lines
> On Sat, Oct 07, 2017 at 03:43:43PM -0400, Robert P. J. Day wrote:
> > >   -r
> > > 	Recursively remove the contents of any directories that match
> > > 	`<file>`.
> > >
> > > or something.
> >
> >   it's been a long week, so take this in the spirit in which it is
> > intended ... i think the "git rm" command and its man page should be
> > printed out, run through a paper shredder, then set on fire. i can't
> > remember the last time i saw such a thoroughly badly-designed,
> > badly-documented and non-intuitive utility.
> >
> >   i'm going to go watch football now and try to forget this horror.
>
> It sounds like the real issue here is that you are interpreting
> "recursively" to mean "globbing".  Your original complaint seemed to
> be a surprise that "git rm book/\*.asc" would delete all of the files
> in the directory "book" that ended in .asc, even without the -r flag.
>
> That's because the operation of matching *.asc is considered
> "globbing".  Now if there were directories whose name ended in .asc,
> then they would only be deleted if the -r flag is given.  Deleting
> directories and their contents is what is considered "recursive
> removal".
>
> That's not particularly surprising to me as a long-time Unix/Linux
> user/developer, since that's how things work in Unix/Linux:
>
> % touch 1.d 2.d ; mkdir 3.d 4.d
> % /bin/ls
> 1.d  2.d  3.d  4.d
> % rm -r *.d
> % touch 1.d 2.d ; mkdir 3.d 4.d
> % rm *.d
> rm: cannot remove '3.d': Is a directory
> rm: cannot remove '4.d': Is a directory
>
> I'm going to guess that you don't come from a Unix background?
  yeah, that must be it, i'm a newbie at linux. let's go with that.
rday
-- 
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
Previous: Theodore Ts'oNext: Paul Smith
Message 9 of 29 in “"git rm" seems to do recursive removal even without "-r"”
  1. Robert P. J. DayOct 7, 2017
  2. Todd ZullingerOct 7, 2017
  3. Robert P. J. DayOct 7, 2017
  4. Jeff KingOct 7, 2017
  5. Robert P. J. DayOct 7, 2017
  6. Jeff KingOct 7, 2017
  7. Robert P. J. DayOct 7, 2017
  8. Theodore Ts'oOct 7, 2017
  9. Robert P. J. DayOct 7, 2017
  10. Paul SmithOct 7, 2017
  11. Robert P. J. DayOct 7, 2017
  12. Junio C HamanoOct 8, 2017
  13. Robert P. J. DayOct 8, 2017
  14. Kevin DaudtOct 8, 2017
  15. Robert P. J. DayOct 8, 2017
  16. Martin ÅgrenOct 8, 2017
  17. René ScharfeOct 8, 2017
  18. Robert P. J. DayOct 8, 2017
  19. Heiko VoigtOct 10, 2017
  20. Robert P. J. DayOct 11, 2017
  21. Paul SmithOct 8, 2017
  22. Theodore Ts'oOct 8, 2017
  23. Robert P. J. DayOct 8, 2017
  24. Theodore Ts'oOct 8, 2017
  25. Jeff KingOct 9, 2017
  26. Robert P. J. DayOct 10, 2017
  27. Junio C HamanoOct 10, 2017
  28. Paul SmithOct 10, 2017
  29. Robert P. J. DayOct 10, 2017

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.