【发布时间】:2013-05-03 16:21:44
【问题描述】:
我想通过在git init 命令上自动创建 .gitignore、README、LICENSE 和其他文件来优化我的 git 工作流程。
为此,我在http://git-scm.com/docs/git-init 对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 吗?光秃秃的?
【问题讨论】:
-
现在没时间写完整的答案,但所有模板文件都进入
.git文件夹