使用git切换分支报错了,提示:please commit your changes or stash them before you switch branches。

提问者:帅平 问题分类:微服务
使用git正在开发新分支,但是需要切换到其他分支报错了,提示:
please commit your changes or stash them before you switch branches。
Git
1 个回答
不长发及腰
不长发及腰
这是git默认的规则,要么提交当前变更,要么暂存本地代码,一般我们选择暂存本地代码,执行:
git stash

这样子就可以暂存代码了,然后切换到其他分支,如果切换到当前分支的话,可以恢复本地暂存:
git stash apply

就可以恢复本地的暂存代码了。
发布于:10个月前 (09-27) IP属地:四川省
我来回答