Suppose you have pushed a few commits to the remote repository (origin), and then realise these should really be in a new branch for development before they get committed to main.
Begin by taking a local copy of the commits. Then revert the remote repository to the commit you want to retain, which in our example means removing the latest 8 commits. Then push that back to the remote repository (origin):
git switch main
git reset --hard main~8
git push origin main --force-with-lease
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0