首先查看远程分支:
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