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

Git: Bulk change of commit dates
When I need to change the commit dates of various commits, I use an interactive rebase and change them one by one. How could I change them all in a single command ? In other words, I need to apply a
Git: Bulk change of commit dates

file history remove

How to Combine Multiple Git Commits into One
An interactive rebase mode allows you to combine your commits into even a single commit. While working in Git, developers often make temporary commits that may have not appropriate commit messages. Before merging those commits to the master, it is necessary to combine them into a single commit with clear and comprehensive commit message.
How to Combine Multiple Git Commits into One
Git: Bulk change of commit dates
When I need to change the commit dates of various commits, I use an interactive rebase and change them one by one. How could I change them all in a single command ? In other words, I need to apply a
Git: Bulk change of commit dates
 
 

Recommendations