(git checkout 某分支)切换分支报错:Please, commit your changes or stash them before you can switch branches.

问题重现:
场景:现在是主分支代码,当我要切换到我的分支提交代码时
我的目的:将主分支合并我的分支代码并且提交
在这里插入图片描述
解决办法:

1.//存到暂存区
git add .
git stash 
2.git checkout  自己的分支名
3.git stash pop  //取出刚刚存到暂存区的代码
4.git add .   git commit -m  '提交代码说明'
5.git checkout master   //切换到主分支
6.git merge 自己的分支名
7.git pull 
8.git push

ok

猜你喜欢

转载自blog.csdn.net/lqlq54321/article/details/114528788