# Prepare new_master git checkout git checkout --orphan new-master git checkout new_master git cherry-pick first-commit-to-include^..last-commit-to-include # Prepare master backup git checkout master git checkout -b master-backup # Replace master git branch -D master git checkout new_master git checkout -b master git push --force origin master # Delete the new_master branch as task is done git branch -D new_master # READ CAREFULLY, delete the master backup if sure that the task completed successfully git branch -D master-backup