how to abandon commits of certain characteristic when using git? -
for example want abandon commits commit message "temp commit", if original commit history follows:
x1 - x2 - x4 -x7 - .... xn-2 - xn-1 - xn \_ x3 -x5 - .. \_ x6 - x8 .. , x4 "temp commit" x6 "temp commit" xn-1 "temp commit"
then commit history rewritten follows, commits x4, x6 , xn-1 abandoned.
if repo have totally 2000 commits, , 500 of commits message "temp commit", 500 commits abandoned, , 1500 commits remains, how git history rewritten?
i know may have filter-branch, know how remove folder using --tree-index, how remove commits of characteristic?
x1 - x2 -x7 - .... xn-2 - xn \_ x3 -x5 - .. \_ x8 ..
from here, try (but have not tested that)
git filter-branch --commit-filter ' msg=$(git log --format=%b -n 1 $git_commit) if [ "$msg" = "temp commit" ]; skip_commit "$@"; else git commit-tree "$@"; fi' head
the function skip_commit defined follows, export or put in .bashrc
skip_commit() { shift; while [ -n "$1" ]; shift; map "$1"; shift; done; }
i'm unsure if works whole repository or 1 branch.
Comments
Post a Comment