On Sun, 8 Jan 2017 07:42:45 -0800 (PST) Fernando Rodriguez <ferchurodrig...@gmail.com> wrote:
> I've seen the command > > git rm log/\*.log > > at [1] , my questions is what is the difference by just doing > > git rm log/*.log > > I'm using a windows version for git and I don't see any difference. This might explain your observation. The "standard" shells on Unix-like operating systems perform so-called pathname expansions by themselves. This means, when you call git rm log/*.log in a shell running on a Unix-like OS, the shell will take that log/*.log pattern and would attempt to expand it by itself--by looking under the "log" directory, enumerating all the files matching the "*.log" pattern there and--should this succeed--replace the original pattern string with one or more *distinct* arguments--the results of the expansion. Say, if there were files 1.log, 2.log and 3.log under the "log" directory at the time of the call, the `git rm` command would receive three distinct arguments: "log/1.log", "log/2.log" and "log/3.log". (If the expansion would fail--that is, no matching entities would have been found, the shell would pass the source pattern "as is" to the command it would call.) On Windows, shells do not do pathname expansion; they don't even do basic grouping of characters, and a Windows process, when it starts, receives either one command line argument -- with all the stuff specified on its command line being passed as is, or none at all (if nothing was specified by the user). It's then the process's own responsibility to parse that stuff however it sees fit. (The programming language the program being called is written in typically offers some help with this in its standard library. Unfortunately, differences in these implementations do exist even between different versions of the standard C library between different releases of that library.) That was for the first part. The second part is that certain Git commands are able to expand globs (those "*" and "**" specs) in pathnames by themselves. To do this, you need to "protect" them from expansion by the shell. The backslash before the '*' character makes the Unix-compatible shell turn the whole sequence "\*" into just '*' while ignoring the special meaning of it. Note that using "\*" on Windows supposes you're doing that in the Git Bash shell -- which is a port of the (Unix-y) bash shell; the stock Windows shells know nothing about the backslash quoting. > [1] > https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.