0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gitでcloneしたリポジトリ全てに個人的なファイルのignoreを設定する方法

Last updated at Posted at 2017-04-25

僕はどうでも良いファイルには、aaa.jsとか付けてコードを試したりするのですが、そういうファイルを設定しておけば、コミット時に選ぶ必要がなくなるので( ・∀・)イイ!!ですね

追記:4/26
コメント欄にて、教えていただいたので追記です。デフォルトの見先は、~/.config/git/ignoreとのことで、こちらに設定すると良いかと思います。

デフォルトの置き場所で指定する方法


$ mkdir -p ~/.config/git
$ cat << EOS >> ~/.config/git/ignore
aaa.txt
EOS

確認方法

$ git status --ignored -s
!! aaa.txt

一度でもglobal設定しているとそちらを見てしまうので、デフォルトを見るように戻したい場合、~/.gitconfigのcore.excludesfileを削除してください。

自分でファイルの置き場を指定する方法


自分のホームディレクトリに、.gitignoreファイルを置いておく場合

git config --global core.excludesfile ~/.gitignore

こちらは、dotfilesをGitHubで管理している人向けでしょうか。

リポジトリ個別指定もある


.git/info/exclude

こちらのリポジトリ個別の方法は知っていたのですが、これだとリポジトリ毎に設定しなければならず辛いなぁと思って使ってませんでした。。。

その他


プロジェクトの.gitignoreを綺麗にしたいという人も少ないと思うので、個人的には、みんな好き勝手に書いても良いと思います。僕は、netbeans使いなので、netbeansのignoreがあるとうれしくなります^^

色々なignoreサンプル


コメントくれた@sakuroさんの記事に書いてあったのですが、こちらもいいですね。全ファイル連結してドカッと指定しておいても良いかもしれませんね。

0
1
2

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?