git 解决主库冲突conflict

来源:互联网 发布:股票盈亏软件 编辑:程序博客网 时间:2024/06/04 18:45

首先查看远程分支:

yishiyaonie:ts-admin liuhanlin$ git remote showoriginqbox

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

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 qboxyishiyaonie:ts-admin liuhanlin$ git merge qbox/masterAuto-merging src/aone.qiniu.com/app/main.goCONFLICT (content): Merge conflict in src/aone.qiniu.com/app/main.goAutomatic 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 statusOn branch masterYour 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.htmlUnmerged paths:  (use "git add <file>..." to mark resolution)    both modified:   src/aone.qiniu.com/app/main.goChanges 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.shyishiyaonie:ts-admin liuhanlin$ git add .yishiyaonie:ts-admin liuhanlin$ git statusOn branch masterYour 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.htmlyishiyaonie: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 basedon your username and hostname. Please check that they are accurate.You can suppress this message by setting them explicitly. Run thefollowing command and follow the instructions in your editor to edityour configuration file:    git config --global --editAfter doing this, you may fix the identity used for this commit with:    git commit --amend --reset-authoryishiyaonie:ts-admin liuhanlin$ git statusOn branch masterYour branch is ahead of 'origin/master' by 7 commits.  (use "git push" to publish your local commits)nothing to commit, working directory cleanyishiyaonie:ts-admin liuhanlin$ git push originCounting 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
1 0