Suppose the current branch is A. Create a new branch from this branch.
git checkout A
git branch B
Now branch B contains the changes you made to branch A. All that remains to be done is to remove the changes from branch A. This can be done as follows:
git reflog
This will give you a list of all the changes the repo went through. Select the HEAD value to which you want to return branch A.
git reset
This will do what you intend to do.
source
share