2017-09-23 28 views
2

我想直接從git外殼添加一個特定的文件到.gitignore。文件無法忽略的是token.mat直接從git外殼添加文件到.gitignore

如果鍵入:

touch .gitignore 

,然後手動開啓的.gitignore用文本編輯器,並添加

token.mat 

保存並關閉,它的工作原理,混帳忽略它(當我在git shell中輸入git status時,我不再看到token.mat)

但是,在git shell中,如果我鍵入:

touch .gitignore 
echo 'token.mat' >> .gitignore 

然後git不會忽略token.mat,當我輸入git status時,我仍然可以看到它。但是,當我打開帶文本編輯的.gitignore時,我看到了列出的token.mat,看起來和我手動添加時完全一樣。

有沒有人知道這是爲什麼,或者我可以直接從git外殼添加文件到.gitignore?

感謝您提前提供任何幫助!

其他詳情:

  • Windows 7專業版,Service Pack 1的
  • Git版本:2.5.3.windows.1
  • 文本編輯器:記事本++
+0

文本編輯器處理文件的添加/處理索引到git項目嗎? – hjpotter92

回答

0

確保你的回聲沒有添加尾隨空格:

echo 'token.mat'>>.gitignore 

那樣,.gitignore應該工作。

此外,2.5是古代:解壓the latest Git,如PortableGit-2.14.1-64-bit.7z.exe,任何你想要的,add it to your %PATH%,並再次檢查。

+0

謝謝VonC!沒有尾隨空間,但移動到Git 2.14的竅門。另外一個說明,對於其他嘗試這種解決方案的人,我也從Git Shell更改爲Git Bash。 –