git多人合作,冲突的解决方案
当使用远程仓库进行多人协作时,冲突的发生是无法避免的,但是如何解决冲突呢?
试想:当你的小伙伴在某一个分支dev
上已经有了新的提交。此时,你需要再次提交到dev
分支
git push origin dev
但是会显示由冲突,此时解决方案是把远程的更新拉下来之后手动解决冲突,再次提交。
git pull
如果此时显示
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> dev
则执行如下命令与远程仓库建立连接(branch_name代表要push到的分支)
git branch --set-upstream-to=origin/branch_name dev`
此时再pull
,手动解决冲突。之后再commit以及push。
git commit -m “fix conflict”
git push origin dev