I would like to optimise my git workflow by automating creation of .gitignore, README, LICENSE and other files on git init
command.
To do that I RTFM of git init
at http://git-scm.com/docs/git-init and it tells me to do one of the following:
- Use
git init --template=<template_directory>
, but it's bothersome.
- Alter the contents of the $GIT_TEMPLATE_DIR environment variable, but I would rather not.
- Set the
init.templatedir
configuration variable. Now we're talking!
So I sudo mkdir /usr/share/git-core/templates/my_template
and touch
some files in it, then I vim ~/.gitconfig
and append:
[init]
templatedir = /usr/share/git-core/templates/my_template
And git config -l
tells me:
...
init.templatedir=/usr/share/git-core/templates/my_template
...
Happy with myself, I go to my development playground directory and:
$ git init
Initialized empty Git repository in /the/current/directory
$ ls -a
. .. .git
Bummer... where are the files? :(
Quick check:
$ ls -a /usr/share/git-core/templates/my_template
. .. .gitignore LICENSE README.md
$ git --version
git version 1.8.2.1
It seems that $ git init --template=/usr/share/git-core/templates/my_template
doesn't work either.
So what is it that I'm doing wrong here? Incorrect configuration directive? Bad template or its location (I'm on OSX)? Should template be a git repo? A bare one?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…