This is the same in the shell as in the other grammars that you mention. A single quoted string will be treated as a "string literal" (so to speak).
The difference between git add '*.txt'
and git add *.txt
is who's doing the matching of the pattern against filenames.
In the case of git add '*.txt'
, git
is doing the pattern matching. Since the shell won't expand the string literal '*.txt'
, git add
will be called with a single argument, *.txt
. git
then does the matching against the filenames available in the whole repository (because... git
).
In the case of git add *.txt
, the shell does the filename matching and will pass a list of matching filenames from the current directory to git add
. Note that if there are no names matching the given pattern, the shell will (usually1) pass the pattern on to git add
unexpanded. If this happens, the result will be the same as if the pattern had been quoted.
1 Usually, but see e.g. the failglob
shell option in bash
. See also comments to this answer.
When git add
gets a filename pattern, it will add not only the files matching in the current directory, but it will add all files that matches in the whole repository (i.e. including any subdirectories). This is why the text in the lower right hand corner says
Wildcards:
We need quotes so that Git will receive the wildcard before our shell can interfere with it. Without quotes our shell will only execute the wildcard search within the current directory. Git will receive the list of files the shell found instead of the wildcard and it will not be able to add the files inside of the octofamily directory.