在这个例子中,我们再次使用之前的“tonychacon”用户来进行示范,源作者提交了一个改动,使得合并请求 和它产生了冲突。现在来看我们解决这个问题的步骤。
$ git remote add upstream https://github.com/schacon/blink 1
$ git fetch upstream 2
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done. Unpacking objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0) From https://github.com/schacon/blink
* [new branch] master -> upstream/master
$ git merge upstream/master 3
Auto-merging blink.ino
CONFLICT (content): Merge conflict in blink.ino
Automatic merge failed; fix conflicts and then commit the result.
$ vim blink.ino 4
$ git add blink.ino
$ git commit
[slow-blink 3c8d735] Merge remote-tracking branch 'upstream/master' \
into slower-blink
$ git push origin slow-blink 5
Counting objects: 6, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 682 bytes | 0 bytes/s, done. Total 6 (delta 2), reused 0 (delta 0)
To https://github.com/tonychacon/blink
ef4725c..3c8d735 slower-blink -> slow-blink
1 将源版本库添加为一个远端,并命名为“upstream”(上游)
2 从远端抓取最新的内容
3 将主分支的内容合并到你的分支中
4 修复产生的冲突
5 再推送回同一个分支
你完成了上面的步骤后,合并请求将会自动更新并重新检查是否能干净的合并。
Figure 98. 合并请求现在可以干净地合并了
网友评论