git 解决主库冲突conflict

首先查看远程分支:

yishiyaonie:ts-admin liuhanlin$ git remote show
origin
qbox

如果缺少远程分支,可以添加远程分支

git remote add qbox https://github.com/qbox/ts-admin.git

其次需要查看分支情况:

yishiyaonie:ts-admin liuhanlin$ git remote show qbox
* remote qbox
  Fetch URL: https://github.com/qbox/ts-admin.git
  Push  URL: https://github.com/qbox/ts-admin.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (local out of date)
yishiyaonie:ts-admin liuhanlin$ git remote show origin
* remote origin
  Fetch URL: https://github.com/jiaojunjiahanlin/ts-admin.git
  Push  URL: https://github.com/jiaojunjiahanlin/ts-admin.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

然后fetch

yishiyaonie:ts-admin liuhanlin$ git fetch qbox
yishiyaonie:ts-admin liuhanlin$ git merge qbox/master
Auto-merging src/aone.qiniu.com/app/main.go
CONFLICT (content): Merge conflict in src/aone.qiniu.com/app/main.go
Automatic merge failed; fix conflicts and then commit the result.

产生冲突confilict的原因是因为不同的人修改了主库相同地方的代码。需要确定以谁的为准。或者都保留。

yishiyaonie:ts-admin liuhanlin$ vim src/aone.qiniu.com/app/main.go
yishiyaonie:ts-admin liuhanlin$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
You have unmerged paths.
  (fix conflicts and run "git commit")

Changes to be committed:

    new file:   src/aone.qiniu.com/app/controllers/token.go
    modified:   website/src/app/manage.html
    new file:   website/src/app/services/tsutilcheck.coffee
    new file:   website/src/app/tsutil/checkbase64.coffee
    new file:   website/src/app/tsutil/checkbase64.html
    new file:   website/src/app/tsutil/checkip.coffee
    new file:   website/src/app/tsutil/checkip.html
    new file:   website/src/app/tsutil/checktoken.coffee
    new file:   website/src/app/tsutil/checktoken.html
    new file:   website/src/app/tsutil/index.html
    new file:   website/src/app/tsutil/layout.html

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

    both modified:   src/aone.qiniu.com/app/main.go

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    deleted:    aone.dockerfile
    deleted:    build_aone.sh

yishiyaonie:ts-admin liuhanlin$ git add .
yishiyaonie:ts-admin liuhanlin$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:

    deleted:    aone.dockerfile
    deleted:    build_aone.sh
    new file:   src/aone.qiniu.com/app/controllers/token.go
    modified:   src/aone.qiniu.com/app/main.go
    modified:   website/src/app/manage.html
    new file:   website/src/app/services/tsutilcheck.coffee
    new file:   website/src/app/tsutil/checkbase64.coffee
    new file:   website/src/app/tsutil/checkbase64.html
    new file:   website/src/app/tsutil/checkip.coffee
    new file:   website/src/app/tsutil/checkip.html
    new file:   website/src/app/tsutil/checktoken.coffee
    new file:   website/src/app/tsutil/checktoken.html
    new file:   website/src/app/tsutil/index.html
    new file:   website/src/app/tsutil/layout.html

yishiyaonie:ts-admin liuhanlin$ git commit -m 'resolve conflict'
[master 4c4f381] resolve conflict
 Committer: LiuHanlin <liuhanlin@yishiyaonie.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

yishiyaonie:ts-admin liuhanlin$ git status
On branch master
Your branch is ahead of 'origin/master' by 7 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean
yishiyaonie:ts-admin liuhanlin$ git push origin
Counting objects: 38, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (34/34), done.
Writing objects: 100% (38/38), 6.74 KiB | 0 bytes/s, done.
Total 38 (delta 18), reused 20 (delta 4)
To https://github.com/jiaojunjiahanlin/ts-admin.git
   a6aef3f..4c4f381  master -> master
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值