0
0

More than 3 years have passed since last update.

Git で、トラッキングしていないファイルをまとめて一括で .gitignore に追加する

Posted at

目的

簡単なプロジェクトで、バージョン管理が必要なファイルが少なく、IDE が吐き出した管理不要なほとんどのファイルを無視したい、といった場合に。

手順

先ずはじめに、バージョン管理が必要なファイルだけ、ファイル名を指定した上で git commit しておきます。

残りは、管理する必要がないファイルなので無視しても良いのですが、git status するたびに出てきてしまうので、.gitignore に入れてしまいたい。でも、手作業でそれをするのは敗北を意味する。

そこで、以下のコマンドを実行します。

git status --porcelain | grep '^??' | cut -c4- >> .gitignore

参考

何度かお世話になっているワンライナーですが、どうも毎回 Web 検索に苦労しているような気がするので、検索が容易になりそうなタイトルで投稿しておきます。

元ネタは以下です。

github - How can I revert this command "git status --porcelain | grep '^??' | cut -c4- >> .gitignore"? - Stack Overflow

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