set -x av stack branch branch-1 echo "Contents of 'A'" > a.txt git add a.txt git commit -m "Added A" echo "Contents of B" > b.txt git add b.txt git commit -m "Added B" echo "Decide to split into two PRs" echo "Creating second branch" av stack branch branch-2 git --no-pager log -n 2 echo "Switching back to first branch" av stack prev git --no-pager log -n 2 echo "Removing second commit from first branch" git reset --hard HEAD~1 git --no-pager log -n 1 echo "Making a fixup" echo "Contents of A" > a.txt git add a.txt git commit -m "A Fixup" echo "Checking status of branch-1" git --no-pager log -n 2 branch-1 echo "Checking status of branch-2" git --no-pager log -n 2 branch-2 echo "Restacking" av stack restack echo "Checking status of branch-1 - should have 2 commits: 'Added A' and 'A fixup'" git --no-pager log -n 2 branch-1 echo "Checking status of branch-2 - should have 3 commits: 'Added A', 'A fixup' and 'Added B'" git --no-pager log -n 3 branch-2 echo "But 'Added B' is missing!"