2
0

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で歴史を改竄する

Last updated at Posted at 2021-01-10

AuthorとCommitterを変更する

GitのCommitユーザを修正する方法 - Qiitaに少し手を加えました。
-- --allですべてのブランチを指定している(らしい)。
--tag-name-filter catでタグが紐付けされているコミットIDも一緒に変えてくれる(らしい)。

git filter-branch -f --env-filter "GIT_AUTHOR_NAME='new'; GIT_AUTHOR_EMAIL='new@example.com'; GIT_COMMITTER_NAME='new'; GIT_COMMITTER_EMAIL='new@example.com';" --tag-name-filter cat -- --all

あるファイルを過去からも消し去る

git filter-branch -f --index-filter 'git rm -rf --cached --ignore-unmatch <プロジェクトのルート(.gitがあるとこ)からの相対パス>' --prune-empty --tag-name-filter cat -- --all

改竄したものをプッシュする時

git push -f
git push origin --tags -f
2
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?