#! /bin/sh rm -rf testrepo git init -b master testrepo cd testrepo # Create the first part of the master branch echo "This is the old master" > README git add README git commit -m "Old master" # Add a PR on top of this beginning of the master branch git checkout -b pr echo "This is the PR" > README git commit -am "PR" # Add a commit to make the master branch advance since the PR git checkout master echo "Master has advanced" > README git commit -am "Old master again" # Create the new main branch from the current state of master # but with no common history (history rewrite). git checkout --orphan main master echo "This is the new main branch" > README git commit -am "Main" # Rebase the pr branch from master to main git rebase -X theirs --onto main master pr