LoginSignup
22
17

More than 5 years have passed since last update.

gitignore_globalでgit管理するファイルをグローバルで設定する

Last updated at Posted at 2018-03-18

.gitignoreにいちいち.DS_Storeとか追加したくない

グローバルで管理できないのか調べてみた。

やりかたは簡単でターミナルで

// グローバルの.gitignoreファイルを作成
$git config --global core.excludesfile ~/.gitignore

すると自分のホームディレクトリ(/Users/UserName)に.gitignore_globalが作成されるので、git管理したくないファイルをここに設定する。

.gitignore_globalでどのファイルを管理すればいいのか?

githubが推奨しているっぽいのは以下の模様。
.gitignore_globalには以下を書いておけば問題ないと思う。

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

参考:github/gitignore

.gitignore_globalを有効化する

ターミナルで以下のコマンドを叩く

// グローバルの.gitignoreファイルを作成
$git config --global core.excludesfile ~/.gitignore_global

もしくは、~/.gitconfigに以下を記述する。↑のコマンドを叩くと.gitconfigに同じ記述がされる

[core]
    excludesfile = /Users/your_user_name/.gitignore_global

プロジェクトごとの.gitignoreではどのファイルを管理すればいいのか?

プロジェクト次第だけど、これもgithubが公開しているものが参考になりそう。
githubが推奨するgitignore

ElmとかElixirとか新しめの言語も対応している。

22
17
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
22
17