0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

gitに変更の追跡をさせない方法

0
Last updated at Posted at 2026-03-30

利用シーンごとにまとめ

毎回調べるのも大変なので備忘録的に。
無視ファイルをたくさん作りすぎると後で困りますので、用法用量はただしく使いましょう。

リポジトリへ登録させないファイル

.gitignore へファイル名を記載する。ローカル環境用のビルド定義やビルド結果、設定などはリモートへ共有しませんから、あらかじめ除外しておきます。

自分のローカルだけにあるファイルをリポジトリへ登録しない

.git/info/exclude へファイル名を記載する。.gitignoreはリポジトリへ登録しますが、このexcludeは初めからリモートへ公開されないファイルです。一時的に作成するファイルなどに使います。

既にリポジトリへ登録されているファイルだが、自分のローカル変更は無視させたい

既にリポジトリへ登録済みのファイルをローカル専用に編集したが、その編集は共有したくない場合に使います。編集してもコミット対象にはならないため、リモートとの差分が発生した場合や、編集した内容をコミット|プッシュさせたい場合には、忘れずに解除しておきましょう。

git update-index --skip-worktree ファイル名

解除する方法

git update-index --no-skip-worktree ファイル名

現在無視しているファイル名一覧を出す

git ls-files -v でファイルの先頭にステータスを出力し、S属性がついているファイルのみフィルタすれば確認できます。

macOS等

git ls-files -v | grep '^S'

windows(grepがない環境)

git ls-files -v | findstr "^S"
0
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?