Start the pagination branch with three commits, typo and "wip" included, while main gains a .nvmrc file pinning Node.js 24 2,131 for nvm 95,199 . Then replay the branch onto the new main:
git switch -c paginate-api
# Edit app.js: add ?limit= (misspelled as limt, as you will notice later)
git commit -qam "Add ?limit= to /api/books"
# Edit app.js and README.md: add ?offset= and document both parameters
git commit -qam "wip"
# Edit app.js: fix the misspelling
git commit -qam "Fix limit typo"
git switch -q main
echo 24 > .nvmrc && git add .nvmrc
git commit -qm "Pin Node.js 24 with .nvmrc"
git switch -q paginate-api
git rebase main
git log --oneline --graph -4Output
Switched to a new branch 'paginate-api' Successfully rebased and updated refs/heads/paginate-api. * 3e5bc80 Fix limit typo * 5341b2a wip * 1ed7071 Add ?limit= to /api/books * e78d7c2 Pin Node.js 24 with .nvmrc
The branch now starts at e78d7c2, with no merge commit (a terminal also shows a "Rebasing (1/3)" counter). Each replay is a cherry-pick (Cherry-Picking): since Git 2.26 1,932 the default merge backend runs ORT for every commit, so renames and conflicts behave as in git merge. git rebase --onto new old moves only the commits after old, to transplant a branch started from the wrong place.