需要切分支但又不想 commit 代码时可以使用 git stash 命令,因为如果直接切换,当前分支修改会跟随到目标分支上。
git stash save "注释":保存当前分支修改至 stash 中,并添加注释。
git stash list:查看所有 stash 的快照信息。
git stash pop:弹出最近一次的 stash 记录应用于当前分支。
git stash apply stash@{num}:弹出指定 num 的 stash 记录应用于当前分支。
注意:stash 是多分支共享的。