発端
私の dotfiles で、 stow git としても、 ~/.gitignore が作られませんでした。
stow -vvv git としたところ、以下のようなログになりました
stow dir is /Users/ndxbn/dotfiles
stow dir path relative to target /Users/ndxbn is dotfiles
cwd now /Users/ndxbn
cwd restored to /Users/ndxbn/dotfiles
cwd now /Users/ndxbn
Planning stow of package git...
Stowing contents of dotfiles/git (cwd=/Users/ndxbn)
Stowing dotfiles / git / .gitconfig
LINK: .gitconfig => dotfiles/git/.gitconfig
Planning stow of package git... done
cwd restored to /Users/ndxbn/dotfiles
Processing tasks...
cwd now /Users/ndxbn
cwd restored to /Users/ndxbn/dotfiles
Processing tasks... done
つまり、「 .gitignore は stow する対象にならなかったよ」ということです。
なぜ stow されなかったか
stow のドキュメント に、以下のようにかかれていました。
If neither the package-local or global ignore list exist, Stow will use its own built-in default ignore list, which serves as a useful example of the format of these ignore list files
もし、package-local な ignore list も global な ignore list もなかった場合、 Stow はビルトインのデフォルトの ignore list を使う。その内容を、 ignore list files の書き方のいち良例として示すな。(意訳)
# Comments and blank lines are allowed.
RCS
.+,v
CVS
\.\#.+ # CVS conflict files / emacs lock files
\.cvsignore
\.svn
_darcs
\.hg
\.git
\.gitignore
.+~ # emacs backup files
\#.*\# # emacs autosave files
^/README.*
^/LICENSE.*
^/COPYING
なるほど、 .gitignore はデフォルトの ignore に含まれるんですね。
どう解決するか
stow のドキュメント に書かれているとおりにやればよいです。
今回の場合は、「dotfiles リポジトリは stow project なリポジトリ」と言えるので、 パッケージルートごとに置けるらしいので、 .stow-local-ignore をプロジェクトルートに置きました。git パッケージルートに置きました。