During each day's work, it always happens, when you have to hold current work and checkout another branch. Of course, you can commit your change first, but what if you don't want to add your changes yet? What if it's important test-code but not in the check-in stage? Is there a way allow me to keep my temporary code and safely checkout another branch?
Yes, there is.
Step1: In your working branch:
$ git stash
Then you will see all your changes have been hidden (Don't worry, they are in a safe place).
Step2: Checkout another branch, for example, your master branch:
$ git checkout master
Step3: Working in master
Step4: Go back to your working branch and get back your previous changes
$ git checkout my-branch
$ git stash pop
Done. That's it.
浙公网安备 33010602011771号