I have worked on a local branch and also pushed the changes to remote.
I want to revert the changes on that branch and do something else on it, but I don't want to lose the work completely. I was thinking of something like create a new branch locally and copy the old branch there, then I can revert the changes and continue working on the old branch.
Is there a better way than this maybe?
Make sure you are in the branch where you want to copy all the changes to. git merge will take the branch you specify and merge it with the branch you are currently in. Just a note that this is going to create a merge commit which may not be what you want.
git checkout old_branch git branch new_branch
This will give you a new branch "new_branch" with the same state as "old_branch".
This command can be combined to the following:
git checkout -b new_branch old_branch
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