I cloned a github repository and made several commits locally. I accidentally made these commits on the master branch when I had intended to make a separate branch for my changes. Is there some way to turn these changes into a new branch and restore the original master branch before I push my changes to the remote?
The steps to merge master into any branch are: Open a Terminal window on the client machine. Switch to the feature branch. Use git to merge master into the branch.
# create a new branch from your current HEAD:
git branch <newbranchname>
# reset your current branch (still master) to the remote master branch:
git reset --hard origin/master
# switch to the new branch:
git checkout <newbranchname>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With