2014-07-17 41 views

回答

1

沒有引號,外殼擴展了*,所以不是將*.txt傳遞給git grep,而是傳遞當前目錄中與此模式匹配的文件列表。

1

如果沒有報價,您的patspec由shell在git獲取之前進行擴展。下面的例子與echo類似。

$ touch contains-x.txt 
$ ls 
contains-x.txt 
$ echo *.txt 
contains-x.txt 
$ echo '*.txt' 
*.txt 
-1

答案很簡單。

當您添加「」與git命令它只是執行它的所有項目,包括子文件夾, 例如

git add *.txt -> will add all the *.txt files in the current directory 
git add '*.txt' -> will add all the .txt file in any directory (recursive) 
+0

你剛纔重申這個問題,你有沒有解釋爲什麼** **。已經有兩個答案解釋了這是因爲沒有引號時,shell在將它傳遞給git之前將glob擴展爲當前目錄中的文件。 –

相關問題