You can use git stash which will save your changes without creating a commit. 1
First save the changes:
$ git stash
Then switch to another branch:
$ git checkout branch-B
When you read, go back to your original branch and discard the changes:
$ git checkout branch-A $ git stash pop
See the documentation above for more details and details about additional use cases.
1 Technically, it creates a commit, but git stash uses some magic, so you donβt actually see a commit, and Git tools can handle these pseudo-statements correctly.
source share