1
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 3 years have passed since last update.

gitのログからパスワードを削除する(git-filter-repo)

Last updated at Posted at 2020-12-29

はじめに

「git filter-branch」を使用してパスワードを実行すると
WARNが発生し「git-filter-repo」が推奨されます

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-repo」は「Git 2.24.0」より導入されました。

インストール方法

brew

brew install git-filter-repo

pip

pip install git-filter-repo

Windows

scoop install git-filter-repo

パスワード変更方法

※例として「-f」を指定しているため注意してください
指定なし →「***REMOVED***」へ変更される

 git filter-repo -f --replace-text  <(echo my_password)

「my_password」から「XXXXXXX」へ変更

git filter-repo -f --replace-text  <(echo “my_password==>XXXXXXX”)

正規表現で変更

### シングル
git filter-repo --replace-text <(echo 'regex:(password:).*==>\1******') 
### ダブル
git filter-repo --replace-text <(echo -e "regex:(password:).*==>\1******") 

ログの確認

git log -p --ignore-space-change 

テスト用ソース

git clone https://github.com/taku333/test-git-filter-repo.git

参考資料

1
1
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
1
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?