LoginSignup
4
4

More than 5 years have passed since last update.

gitで自分用テンプレートを使う

Posted at

オレオレgitテンプレートの定義

$ tree $HOME/work/.git_template
/home/XXX/work/.git_template
-- hooks
   -- post-flow-release-finish
   `-- post-flow-release-start
`-- info
    `-- exclude

2 directories, 3 files

git clone OR git init

  1. -template オプションでtemplateディレクトリを指定 (git init --template=$HOME/work/.git_template)
  2. 環境変数で指定(export GIT_TEMPLATE_DIR=$HOME/work/.git_template)
  3. .gitconfigで指定(git config --global init.templatedir $HOME/work/.git_template)

適用例

/tmp$ rm -rf test
/tmp$ mkdir test
/tmp$ cd test
/tmp/test$ touch a
/tmp/test$ git init --template=$HOME/work/.git_template
Initialized empty Git repository in /tmp/test/.git/
/tmp/test$ tree . .git
.
`-- a
.git
-- HEAD
-- config
-- hooks
   -- post-flow-release-finish
   `-- post-flow-release-start
-- info
   `-- exclude
-- objects
   -- info
   `-- pack
`-- refs
    -- heads
    `-- tags

8 directories, 6 files
/tmp/test$
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4