LoginSignup
4
4

More than 5 years have passed since last update.

gitignoreの除外ファイルの記述に手間取った話

Posted at

はじめに

例えばこういったディレクトリ構成があるとします。
image.png

ここで、a配下は基本的に無視したい。
でも、e.txtだけは差分監視するようにしたい。
そんな設定にしようとしたところ、詰まったので備忘録的に残しておきます。

gitignore(初期)

.gitignore
/a
...
...

gitignore(正解)

.gitignore
/a/*
!/a/b
/a/b/*
!/a/b/c
/a/b/c/*
!/a/b/c/d
/a/b/c/d/*
!/a/b/c/d/e.txt

このように、各階層ごとに無視してほしいディレクトリと無視してほしくないディレクトリを交互に記述していく必要がある模様。

gitignore(失敗例)

こういう書き方ができると思っていた時期が私にもありました。

.gitignore
/a/*
!/a/b/c/d/e.txt
.gitignore
/a
!/a/b/c/d/e.txt

所感

本当にいちいちこういう面倒くさい書き方しないといけないのかなぁ。

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