头图

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

Demo Controller

we'll staging it

暂存

确认已保存

Then we can safely switch branches

切换分支

We restore the code we just saved

恢复

Finally, don't forget to empty

清空


冯文议
183 声望20 粉丝

软件开发工程师,专注于程序设计与开发。