When should I use quotes in git? -


for sake of example, presume have

directory/       nameoffile.txt       nameofdirectory/                 ... 

i have been using format git add directory/nameof* in different documentation, have seen git add 'directory/nameof*'.

just tried git add "directory/nameof*" , worked.

also tried git commit -m message no quotes , worked too.

so git allow no quotes/quotes interchangably or circumstances or versions? beyond allow, standard protocols no quotes, single, , double quotes?

this question has nothing git , shell.

most shells "tokenize" command line -- is, split sequence of discrete elements -- using whitespace. so, example...

rm 1 file 

...will attempt remove file named one , file named file, whereas...

rm 'one file' 

...will attempt remove single file named one file. examples, using quotes or not doesn't particularly matter, because none of filenames contains spaces. 1 exception commit example; if message contains spaces need quote it, other wise you'll get:

$ git ci -m test error: pathspec 'is' did not match file(s) known git. error: pathspec 'a' did not match file(s) known git. error: pathspec 'test' did not match file(s) known git. 

and in fact, there's 1 other point worth considering: quoting text typically inhibits wildcard expansion, if have file named nameoffile.txt , this...

rm nameof*.txt 

...it work fine, if this:

rm 'nameof*.txt' 

...i error:

rm: cannot remove `nameof*.txt': no such file or directory 

however, looks git performs filename expansion if shell doesn't it, examples wildcards work.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -