我想通过自动创建 .gitignore、README、LICENSE 和其他git init
命令文件来优化我的 git 工作流程。
为此,我git init
在http://git-scm.com/docs/git-init进行 RTFM,它告诉我执行以下操作之一:
- 使用
git init --template=<template_directory>
,但它很麻烦。 - 更改 $GIT_TEMPLATE_DIR 环境变量的内容,但我不想这样做。
- 设置
init.templatedir
配置变量。现在我们在说话!
所以我sudo mkdir /usr/share/git-core/templates/my_template
和touch
其中的一些文件,然后我vim ~/.gitconfig
并附加:
[init]
templatedir = /usr/share/git-core/templates/my_template
并git config -l
告诉我:
...
init.templatedir=/usr/share/git-core/templates/my_template
...
对自己很满意,我去我的开发游乐场目录并:
$ git init
Initialized empty Git repository in /the/current/directory
$ ls -a
. .. .git
无赖...文件在哪里?:(
快速检查:
$ ls -a /usr/share/git-core/templates/my_template
. .. .gitignore LICENSE README.md
$ git --version
git version 1.8.2.1
看来这$ git init --template=/usr/share/git-core/templates/my_template
也行不通。
那么我在这里做错了什么?配置指令不正确?错误的模板或其位置(我在 OSX 上)?模板应该是 git repo 吗?一个光秃秃的?