Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,364,888
Community Members
 
Community Events
168
Community Groups

When clone in SourceTree, warning: templates not found is shown

Edited

 

First of all, I am on macOS.

This warning is encountered by many users:
https://community.atlassian.com/t5/Git-questions/About-git-path-for-Sourcetree/qaq-p/186483
https://community.atlassian.com/t5/Sourcetree-questions/Sourcetree-git-cloning-warning-templates-not-found/qaq-p/253348

In conclusion, the solutions are to use system git or change the git template directory to

/Applications/SourceTree.app/Contents/Resources/git_local/share/git-core/templates

I have no problem in cloning my source code (it is just warning and do not block me from cloning). In many times, I just ignored it and finally this warning bites me hard.

I notice that my pre-commit hooks (setup by husky) are not running in my js project. After long time debugging, I find that .git/hooks is missing. And after several trial-and-errors, I find that when cloning via SourceTree, .git/hooks is not being created and it is due to the missing template warning!

By default, the template directory contains hooks, description and info directories. These will be copied to project directory during `git init` or `git clone`. But as template is not found by SourceTree, they are not copied!

It looks like SourceTree assumes template directory is /usr/local/git/share/git-core/templates which is not the case as documented in https://git-scm.com/docs/git-init#_template_directory

Can anyone take a look on this aged problem? It is affecting my team's workflow and obviously asking every team members to set SourceTree config is not one of the best solution.

 

2 answers

I found that the issues was that the .gitconfig file in my home directory wasn't pointing to the location of the templates directory. If you open the .gigconfig file there will be a templatedir property in the intit section

[init]
templatedir = some_wrong_path/share/git-core/templates

 

If you can figure out where the templates actually, probably under one of the sourcetree or git folders, you can change the path. One thing I noticed is that the git version I was using wanted to add its git bath so I just needed.

[init]
templatedir = /share/git-core/templates

0 votes
Manju Atlassian Team Aug 14, 2018

Have you tried switching to System Git in Sourcetree? If your setup works on terminal and everything is setup with the system git path, you should switch to using System Git. Navigate to Preference window's Git tab and click on Use System Git button to switch. 

Yes I tried, and it worked (i.e. my hooks directory got created).

What I don't understand is why the embedded git is looking for git template at /usr/local/git/share/git-core/templates (I got this from the warning message in SourceTree) rather than the one documented at https://git-scm.com/docs/git-init#_template_directory 

The default template dir is /usr/share/git-core/templates. If git is installed locally, I guess it should be /usr/local/share/git-core/templates. 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events