git rebase -i --root
git rebase main -x 'make clang-reformat && git commit --amend'
wget https://raw.githubusercontent.com/newren/git-filter-repo/main/contrib/filter-repo-demos/lint-history chmod +x lint-history
Apply patch from https://github.com/newren/git-filter-repo/issues/552
./lint-history \ --refs main..feeat-clang2 \ --relevant 'return filename.endswith(b".c") or filename.endswith(b".h")' \ clang-format-16 -i
Automatically reword all rebased commits
Following will automatically execute default editor for every commit:
git rebase origin/master -x 'git commit --amend'
Iterate through history and remove all files mathcing pattern:
git filter-branch --tree-filter 'rm -f m* z* x* w* s* r*' --prune-empty HEAD
sudo apt install git-filter-repo
Remove workspace dir:
git filter-repo --path workspace --invert-paths --force
git filter-repo --path-rename 'MYDIR/:'
git filter-repo --path-rename ':app/'
git filter-branch --tree-filter 'git ls-files -z | xargs -0 dos2unix' -- --all
filter-branch
makes backup by creating refs/oribinal/*
. To clean all backups refs from rewriting history tools:
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d git for-each-ref --format="%(refname)" refs/replace/ | xargs -n 1 git update-ref -d