LoginSignup
6
6

More than 5 years have passed since last update.

Git サブディレクトリ配下の特定ファイルのみ対象とする

Last updated at Posted at 2014-03-07

以下のようなフォルダ構成で、/hoge/file1.txtだけcommitしたいよ、という場合。

/hoge
/hoge/file1.txt
/hoge/file2.txt
/hoge/file3.txt
/.gitignore

.gitignore をこのようにする。

*.*
!/hoge/file1.txt

/*というかどこかに/を入れるとその配下のディレクトリが除外対象になってしまい、後から!で指定しても除外されたままになってしまう。
そのため、「あらゆるファイル」のみを除外し、そこから対象のファイルを!で設定するようにする。

6
6
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
6
6