Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?