LoginSignup
12
8

More than 3 years have passed since last update.

git filter-repoってなんぞ

Posted at

ある日、いつものようにgitで歴史改竄をしようとしたらこんな警告文が…

WARNING: git-filter-branch has a glut of gotchas generating mangled history
         rewrites.  Hit Ctrl-C before proceeding to abort, then use an
         alternative filtering tool such as 'git filter-repo'
         (https://github.com/newren/git-filter-repo/) instead.  See the
         filter-branch manual page for more details; to squelch this warning,
         set FILTER_BRANCH_SQUELCH_WARNING=1.

要するにgit filter-branchが新しくなんかいい感じになったgit filter-repoがあるらしいです。

インストール

デフォルトではインストールされていないので、追加でインストール作業が必要です。
Homebrewだとこんな感じ。それ以外はこちらを見てください

brew install git-filter-repo

(Windowsはpipからインストールするしかないのか…)

使い方

マニュアルはこちら。オプションはgit filter-branchよりわかりやすくなってますね。

フォルダ移動
git filter-repo --to-subdirectory-filter my-module
src以下だけ残す
git filter-repo --path src/
ReadMe.mdだけ消す
git filter-repo --path ReadMe.md --invert-paths
12
8
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
12
8