script visible at https://github.com/xloem/wheecode/commit/a21120eae018a12d4161991946d57a0a530... it's just quick pasta the three lines of interest are 85, 99, and 114 here are lines 85 and 99: 85: transform=--path-rename="$srcname":"$dstname" 99: git filter-repo $transform --source "$SRC_REPO" --target "$DST_REPO" --refs "$SRCTIP" --replace-refs update-and-add i don't like sharing these two lines but they happen prior to the next one. git-filter-repo is an evil bookburning tool for changing the entirety of git history such that something was different. in the world wide web i see, it seems presently recommended by the git project over git-filter-branch and such. i rename a subfolder into a new repository and then rebase only the commits of interest. here's line 114: 114: MERGE_COMMIT="$(git commit-tree -m "Rebased and merged $1 from $srcname into $dstname." "$DST_TREE" -p "$DSTTIP" -p "$SRCTIP")" git commit-tree is a really cool plumbing command for creating a manual commit. of course, it would be nice if git-merge let you make arbitrary merge commits itself (it only merges the working tree) but as a nerd i find internals pretty fun when i have time to engage them. -m gives the message for the new commit, the positional parameter is the tree associated with the commit (which I got with `git rev-parse HEAD^{tree}` where ^{tree} is a magic git suffix that means the tree rather than the commit) and each -p is a parent for the commit. the new commit hash is output on stdout.