How to do it...

  1. 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
  1. 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
  1. 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, ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.