stash
, the meaning of hiding.
Overview
If there is such a scenario, we are developing something and need to switch branches to handle something. At this time, besides pushing the code to the warehouse, is there any other good way? The answer is yes, which is the topic to be shared today: git stash
. It's important to note that this can be done assuming we won't be stuck on other branches for too long. After a long time, we may forget, resulting in loss of code.
Order
save
git stash save 'develop a api ....'
list
git stash list
recover
git stash apply stash@{0}
Stash is a stack, which means that the last one saved is at the top, which is 0.
So, you want to restore the last one, then {0}
.
empty
git stash clear
example
Suppose we write a DemoController
we'll staging it
Then we can safely switch branches
We restore the code we just saved
Finally, don't forget to empty
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。