LoginSignup
5
11

More than 5 years have passed since last update.

【git】プロジェクトを跨いだグローバルなgitignoreを作成する

Last updated at Posted at 2017-04-11

ユースケース

ローカル環境にある.idea/や.DS_storeなどは各個人の環境で生成される。
プロジェクト共通の.gitignoreに、書くのは適切ではない。

ローカル環境のみ適応する.gitignoreを作成

.gitconfigに、ローカル環境の.gitignoreを読み込ませる。
下記コマンドで、commit時にホームディレクトリにある.gitignore_globalに書かれたファイルをcommit対象から外す。

ターミナル.
$ git config --global core.excludesfile ~/.gitignore_global

.gitignore_globalを編集する。
普段プロジェクトのルートに置く.gitignoreと同じ記述方法

ターミナル.
$ vi ~/.gitignore_global
~/.gitignore_global
.idea/
.DS_Store

設定後、プロジェクトのルートでgit init
これで~/.gitignore_globalのファイルは、gitのcommit対象にはならない。

5
11
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
5
11