This is achievable through the creation of a new branch that starts from the current state in which you do not have to lose your work. Here is how to create it:
Create a New Branch:
Code
git checkout -b new-branch
Switch back to your old branch:
Code
git checkout old-branch
Revert the changes on the old branch:
If you have made a last commit in your code and want to undo that commit.
The code will be:
Code
git reset --hard HEAD~1
That means you could hold all of your new branch changes there, reverting later when you may need to again start work on the old branch.