Help us understand the problem. What is going on with this article?

.gitignoreで.DS_Storeを削除しよう

More than 1 year has passed since last update.

はじめに

GitHubにpushした際に.DS_Storeが上がってしまった時の対処法です。

対処法

.gitignoreの作成

$ touch .gitignore

.gitignoreの記述

.gitignore
.DS_Store

キャッシュの削除

$ git rm -r --cached .

pushする

$ git add .
$ git commit -m "create .gitignore"
$ git push origin master

追記

.gitignore をプロジェクトの度に作成したり、 .DS_Store 等を記述したりするのは正直面倒です。
.gitignore_global を作成し、グローバルに設定することで面倒な作業をなくすことができます。

作成する

$ touch .gitignore_global

.gitignore を有効化するか ~/.gitconfig に直接追記する

$ git config --global core.excludesfile ~/.gitignore_global
.gitconfig
[core]
    excludesfile = /Users/your_user_name/.gitignore_global

.gitignore_global に .DS_Store を追加する

.gitignore_global
.DS_Store

参考資料
グローバルで.gitignoreを適応する

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした