0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

.DS_storeとはなんなのか?毎回.gitignoreに入れるのめんどくさい

Posted at

はじめに

macでプログラミングしていると、勝手に現れる.DS_Store
.gitignoreに入れるファイルであることしか知らないので、調べてまとめた。

.DS_Storeとは何か?

.DS_Store(Desktop Services Store)は、macOSのFinderが自動的に生成する隠しファイルである。このファイルは、アイコンの位置やウィンドウサイズなどのメタデータが含まれている、

このファイルをgit等のバージョン管理含まれると、他のOSのユーザーには不要なファイルとなる。また、過去にあったファイル名などの情報がファイル内に残っている可能性もあり、セキリュティ上の懸念に繋がるため。

そのため、.gitignoreに.DS_Storeを書いて、バージョン管理しないようにする。
しかし毎回.gitignoreに.DS_Storeを書いていたが、Global設定をすることで毎回.gitignoreに.DS_Storeを書かなくていいらしい。

そこで、プロジェクトごとに.DS_Storeをignore設定するのではなくて、グローバルに設定してみた。

グローバルなgitignoreを設定する方法

Gitはデフォルトで、~/.config/git/ignore へignoreの設定を参照する。つまり、ここに書いておけば、すべてのプロジェクトに適用される。

1 ignoreファイルを格納するためのディレクトリを作成

mkdir -p ~/.config/git/

2 ignoreファイルを作成し、全プロジェクトでignoreしたい内容を入れる

cursor ~/.config/git/ignore

cursorエディタを使っているが、ignoreファイルを作成して、その中に.DS_Storeを書いて保存。
このファイルに、.DS_Storeを入れておけば、DS_Storeは自動でGitの追跡から除外される。

参考文献 (2025/04/08 アクセス)

公式ドキュメント : https://git-scm.com/docs/gitignore
https://bossagyu.com/blog/025-git-ignore/
https://yoshitaku-jp.hatenablog.com/entry/2021/12/03/180000
https://zenn.dev/thousanda/articles/5c7dcd8d6bd9bd

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?