Unless I’m misunderstanding you can checkout your previous branch with
git checkout -
(The same way you can use ‘cd -‘ to change to your previous directory)