You can achieve this using a git template directory
git config --global init.templatedir /path/to/template
You can then add files to the folder /path/to/template/hooks
and they will be automatically copied to the .git/hooks
folder on git init
You can place the .gitignore contents you want in a file you name exclude
in the folder /path/to/template/info
. Then it will effectively be a .gitignore
file in all new repositories created by git init
.
Note that the .gitignore
file is not populated with the content of exclude
. On git init
the exclude
file in the info
folder will be copied into the .git/info
folder of your git repository. This will cause the file patterns listed in exclude
to be ignored, just like patterns in .gitignore
.
If you are on unix, there is even a default template directory /usr/share/git-core/templates
. On MacOS the template directory is in /usr/local/share/git-core/templates