0 votes
1 view
in Devops and Agile by (28.4k points)

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 creating 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 maybe? Or how do I do this?

1 Answer

0 votes
by (20k points)

$ git checkout old_branch

$ git branch new_branch

This command 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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...