環境:
- Win10 x64
- Git windows客戶端(下載自 https://git-scm.com/)
- SourceTree 1.9.6.1(使用系統安裝的Git,而非SourceTree內嵌的Git)
問題:
今天再clone 源碼時,出現一個警告信息“warning: templates not found C:\Program Files\Git\share\git-core\templates”。於是想辦法解決一下。
分析:
看提示是沒有找到tamplate文件。按照錯誤提示中的路徑去找,確實沒有對應的目錄。我的Git安裝目錄下只有這些文件夾:
於是搜索了一下templates目錄,原來它在C:\Program Files\Git\mingw64\share\git-core\templates 這個位置。
原因找到了:原來SourceTree去了一個錯誤的位置找template文件,當然找不到了。我們把正確的位置告訴它就好了。
解決辦法
1. 在SourceTree的設置頁面找遍了也沒找到設置template的地方。於是想辦法直接修改配置文件。
2. 由於SourceTree是調用了Git,於是我們去修改Git的配置文件。
3. 在WIn10系統,Git的配置文件位於C:\Users\<登錄用戶名>\.gitconfig。使用文本編輯工具打開並加入如下幾行:
[init]
templatedir=C:/Program Files/Git/mingw64/share/git-core/templates