Git merge合并分支的总结

创建分支并合并到主分支


  • 创建分支
git checkout -b mybranch
git push origin mybranch
git add .
git commit -m "info..."
git pull
git push

说明:pull报错 vim .git/config 复制拷贝分支信息

  • 把我的mybranch分支合并到主分支explorer
 git checkout explorer
 git merge mybranch 
 git status
 git push

git mrege 后,status提示有冲突的解决


  • 手动修改文件解决冲突,然后再次提交
git add .
git commit -m "info"
git pull
git push

遇到的问题


  • git pull后又提示冲突,并不能push,然后解决再add陷入死循环,甚至不能重置项目,只能删项目文件夹,重新clone
  • 自行找到的土办法

    • 在第一次git mrege出现冲突并手工修改完后,按一下步骤借助stash处理,其实最开始我stash是为了保存住代码,歪打正着
git add .
git stash 
git pull
git stash apply stash@{0}
git commit -m "update"
git pull
git push

说明:这样git log中就像是把之前在子分支上的所有提交归纳为一次普通提交,不会有mrege的提示,以前在我的子分支上的commit信息也没了,如各位看官有什么科学的办法,劳请告知

标签: GIt, git mrege