相关疑难解决方法(0)

在git init上设置默认目录结构

我想通过自动创建.gitignore,README,LICENSE和其他git init命令文件来优化我的git工作流程.

要做到这一点,我git inithttp://git-scm.com/docs/git-init的 RTFM,它告诉我做以下其中一项:

  1. 使用git init --template=<template_directory>,但这很麻烦.
  2. 更改$ GIT_TEMPLATE_DIR环境变量的内容,但我不愿意.
  3. 设置init.templatedir配置变量.现在我们正在谈论!

所以我sudo mkdir /usr/share/git-core/templates/my_templatetouch它中的一些文件,然后我vim ~/.gitconfig和追加:

[init]
    templatedir = /usr/share/git-core/templates/my_template
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

糟糕......文件在哪里?:(

快速检查:

$ ls -a /usr/share/git-core/templates/my_template
.   ..  .gitignore  LICENSE README.md
$ git --version
git version 1.8.2.1
Run Code Online (Sandbox Code Playgroud)

它似乎$ git init …

git templates

30
推荐指数
3
解决办法
2万
查看次数

标签 统计

git ×1

templates ×1