dotfiles
- ホームディレクトリのドットファイルを~/dotfilesからシンボリックリンクする形で管理している。
- ホームディレクトリには、グローバルな~/.gitignoreがある。
- しかし、~/dotfilesディレクトリには、このディレクトリ自体を管理するためのローカルな.gitignoreがある。
- 被る。
- どうしよう。
参考
1.~/.gitignoreだけ別途管理する
例として、上記コマンドラインツールを用いてGistで管理する。
~/.gitignoreをGistへアップロードする。
$ gist ~/.gitignore
https://gist.github.com/catfist/6df2cc0e4d534af3a95c
以後、アップデートは以下のコマンドで行う。
$ gist -u https://gist.github.com/catfist/6df2cc0e4d534af3a95c ~/.gitignore
デプロイは、以下のコマンドで行う。コード内容だけを得るため、GistのRAWページを取得する。
curl -L https://gist.github.com/catfist/6df2cc0e4d534af3a95c/raw > ~/.gitignore
2.~/dotfilesでは、.gitignoreを使わない
代わりに、.git/info/excludeに記述する。記述方法は.gitignoreの場合と同じである。
~/dotfiles/.git/info/exclude
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
hub
というか、特に.gitignore自体をGit管理したいのでない限り、基本、.git/info/excludeで指定したほうがスマートな気がする。
dotfilesリポジトリにおいてのみ、.gitignoreをトラックする
実は、~/.gitignoreに.gitignoreが含まれている。
これを追加するには、-f
オプションを利用する。
$ git add .gitignore # 無視されてしまう
The following paths are ignored by one of your .gitignore files:
.gitignore
Use -f if you really want to add them.
$ git add -f .gitignore # 強制的に追加する
$ git st # トラックされている
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: .gitignore