git filter-branch

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2020 Mar 11 7:28
Editor
Edited
Edited
2024 Oct 18 20:29

Remove File

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch "(.yarn*|.pnp*|yarn.lock|package-lock.json)"' --prune-empty -- --all git push origin --force --all
safer --force-with-lease

git filter-repo

filter repo change date

# Save this as ../change_time.py def handle(commit): "Reset the timezone of all commits." date_str = commit.author_date.decode('utf-8') [seconds, timezone] = date_str.split() if 1606834800 < int(seconds) < 1606921200: print(seconds) new_date = f"{int(seconds)+86400} +0900" commit.author_date = new_date.encode('utf-8') handle(commit)

Change Commit user

git filter-branch -f --env-filter \ "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='newemail'; \ GIT_COMMITTER_NAME='committed-name'; GIT_COMMITTER_EMAIL='committed-email';" HEAD
 

delete commit by date

git filter-branch -f --commit-filter ' if [ "$GIT_AUTHOR_NAME" = "seongland" ]; then skip_commit "$@"; else git commit-tree "$@"; fi' HEAD
git filter-branch -f --commit-filter ' STDIN=$(< /dev/stdin) if [ "$STDIN" = "meta: add \`.github\` folder" ] then skip_commit "$@"; else git commit-tree "$@"; fi' HEAD git push origin --force --all
git filter-branch -f --commit-filter ' STDIN=$(< /dev/stdin) if [ "$STDIN" = "chore: add .github folder basic" ] then skip_commit "$@"; else git commit-tree "$@"; fi' HEAD git push origin --force --all
do not use cat - (commit message removed)
 
 
 
 
 

filter-repo

file history remove

 
 

Recommendations