文章目录
- 1 问题背景
- 2 解决问题
- 3 心得
1 问题背景
- commit之后,有文件冲突
- 然后执行 git fetch upstream
- 再执行 git rebase upstream/dev
- merge代码
- git push
- 提示当前不在分支
- git branch查看 (no branch, rebasing dev)
2 解决问题
- git rebase --continue
- git checkout dev(切换到dev)
- 提示有提交将丢失
Warning: you are leaving 2 commits behind, not connected to
any of your branches:
6e17ea522 merge error
ed21b7511 handle sp without leading sc when update
If you want to keep them by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> 6e17ea522
-
git branch 新的分支 6e17ea522(注意上图中第10行的提示)
-
git checkout 新的分支
-
git push orgin 新的分支:dev
-
提示需要commit: hint: (. ‘git pull …’) before pushing again.(merge的代码没有commit)
-
git commit -m ‘test’(或者通过idea git窗口 commit, 可能会出现确认message的情况,输入message后,输入:wq, 也lunix上退出vim编辑一样)
-
再次 git push origin 新的分支:dev
成功!
- 最后要做的就是删除原来的本地dev分支,重新拉取一下就好
- git branch -D dev
- git checkout -b dev origin/dev
- git branch -D 新的分支(不需要了)
3 心得
- 根据提示来,不要反抗