- Our template directory is ready, and we can use it, as described earlier, as a command-line option, an environment variable or, as in this example, to be set as a configuration:
$ git config --global init.templatedir ~/.git_template
- Now, all Git repositories we create using init or clone will have the default files of the template directory. We can test whether it works by creating a new repository as follows:
$ git init template-example $ cd template-example
- Let's try to create a .txt file and see what git status tells us. It should be ignored by the exclude file from the template directory:
$ echo "this is the readme file" > README.txt $ git status
The exclude file worked! You can put in the file endings yourself, or just leave it blank and keep to the .gitignore files.
- To test whether the commit-msg hook works, let's try to create a commit. First, we need a file to commit. So, let's create that and commit it as follows:
$ echo "something to commit" > somefile $ git add somefile $ git commit -m "Committed something"
- We can now check the history with git log:
$ git log -1 commit 1f7d63d7e08e96dda3da63eadc17f35132d24064 Author: John Doe <[email protected]> Date: Mon Jan 6 20:14:21 2014 +0100 Committed something Hi from the template commit-msg hook