git协同开发时冲突的解决

假定A,B两位开发人员同时修改了一个文件A人员先提交后,B人员在提交到远程会报错,如图:

在这里插入图片描述

B人员的解决办法

1.先执行拉取操作

git pull origin master

现在文件处在,merging冲突的状态,需要手动修改文件在这里插入图片描述
把文件修改好了以后,直接git add . git commit -m “***” 后面不能带文件
然后 git push origin master

Administrator@PC201812301553 MINGW64 /d/workspaces/weChat/hushan (master)
$ git pull origin master 			#B提交,发现冲突,报错
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/LORTER/hushan
 * branch            master     -> FETCH_HEAD
   9fa2045..fa57aa6  master     -> origin/master
Auto-merging huashanjianfa.txt
CONFLICT (content): Merge conflict in huashanjianfa.txt
Automatic merge failed; fix conflicts and then commit the result.

Administrator@PC201812301553 MINGW64 /d/workspaces/weChat/hushan (master|MERGING)
$ vim huashanjianfa.txt		#对文件进行修改

Administrator@PC201812301553 MINGW64 /d/workspaces/weChat/hushan (master|MERGING)
$ cat huashanjianfa.txt
华山剑法,天下无敌
狐冲剑法,天下第一,我的剑比岳不群更剑! edit by lhc! edit by ybq!
我的剑是我的剑,你的剑是真的剑!

Administrator@PC201812301553 MINGW64 /d/workspaces/weChat/hushan (master|MERGING)
$ git status		#工作区有变动,但未提交到本地仓库
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   huashanjianfa.txt

no changes added to commit (use "git add" and/or "git commit -a")

Administrator@PC201812301553 MINGW64 /d/workspaces/weChat/hushan (master|MERGING)
$ git add .			

Administrator@PC201812301553 MINGW64 /d/workspaces/weChat/hushan (master|MERGING)
$ git commit -m "resover"			#提交到本地仓库
[master 787ec2a] resover

Administrator@PC201812301553 MINGW64 /d/workspaces/weChat/hushan (master)
$ git push origin master		#推送到远程
Enumerating objects: 10, done.
Counting 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值