LoginSignup
3
4

More than 3 years have passed since last update.

.DS_storeとgitignore_globalの設定方法

Posted at

はじめに

gitignore_globalを設定した時にどこに配置すべきかわからなかったため、
gitconfigの仕組みを学びながら解決法をまとめました。

できるようになること

  • gitignore_globalの適切な配置場所がわかる
  • .DS_storeをignoreできる

設定ファイルの影響範囲と置き場所

gitの設定ファイルが影響を及ぼす範囲は3段階あります。

1. local(ローカル)

対象リポジトリ内の
.git/config

2. global(ユーザ全体)

HOMEディレクトリ配下の
~/.gitconfig

3. system(システム全体)

systemについては、Gitの種類、バージョン、インストールなどによって
格納場所が変わるようです。
/usr/local/etc/gitconfig
/usr/local/git/etc/gitconfig

gitignore_globalの格納場所

configの影響範囲を考えると、HOMEディレクトリ配下に格納するのが良いと考えられます。
~/.gitignore_global がよさそう

配置したgitignore_globalに.DS_storeを追記します。

~/.gitignore_global
.DS_store

設定を有効にします。
git config --global core.excludesfile ~/.gitignore_global

~.gitconfigに以下の内容が記載されており、
設定が有効になっていることを確認します。

~.gitconfig
[core]  
        excludesfile = /Users/(username)/.gitignore_global

以上の設定により、
.DS_storeをプロジェクト毎にgitignoreする必要がなくなります。

参考にさせていただいた記事

stackoverflowの記事
https://stackoverflow.com/questions/18393498/gitignore-all-the-ds-store-files-in-every-folder-and-subfolder?rq=1

3
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
3
4