首次fork

具体步骤:

  1. 进入自己fork它人项目的界面,点击【Pull request】

image.png

  1. 在进入的界面中,右边改为被fork的项目,左边改为自己需要更新的fork过来的项目

image.png

  1. 出现变更的文件后点击点击【create pull request】
  2. 随后点击【Merage pull request】


多次更新fork后出现【This branch has conflicts that must be resolved】冲突提示

需要工具:GitHub DesktopGit
具体步骤:

  1. 下载并安装好GitHub Desktop后clone自己想要解决冲突的项目文件到本地[3]
  2. 下载并安装好Git后[4],通过cmd进入上一步中clone的本地项目根目录[5]

image.png

cd /d C:\Users\yinian\Documents\Github\BILIBILI-HELPER

随后使用如下git命令
Snipaste_2021-01-12_15-47-19.png

git checkout -b JunzhouLiu-main main git pull https://github.com/JunzhouLiu/BILIBILI-HELPER.git main

git checkout main git merge —no-ff JunzhouLiu-main git push origin main

2.1 逐条解释[6]
假设从A合入到B:B <== A。
A: https://github.com/apache/incubator-apisix.git
B: xxxx/incubator-apisix.git

Step 1 : From your project repository,check out a new branch and test the changes.

  • git checkout -b JunzhouLiu-main main

    1. #建立B的JunzhouLiu-main分支,并切换到JunzhouLiu-main<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/1240869/1610441023588-5c7e6dd5-cd45-4cc7-bef8-bf198e1089e2.png#height=49&id=ami4N&margin=%5Bobject%20Object%5D&name=image.png&originHeight=49&originWidth=867&originalType=binary&ratio=1&size=8974&status=done&style=none&width=867)
  • git pull git://github.com/JunzhouLiu/BILIBILI-HELPER.git main

    1. #将A最新的内容合入JunzhouLiu-main<br /> #因为有冲突,所以上条执行时,会提示冲突:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/1240869/1610440962182-78e246ff-90af-4abe-97f4-79327338d483.png#height=147&id=r6v73&margin=%5Bobject%20Object%5D&name=image.png&originHeight=147&originWidth=1111&originalType=binary&ratio=1&size=29954&status=done&style=none&width=1111)
  • 手动打开冲突文件,根据提示修改,删除冲突的内容,留下想要的结果内容。

    1. #修改后注意在Github Desktop上点击相应的merge按钮<br /> #否则就使用<br />git add [files that were conflicted]<br />git commit,将冲突修改提交到本地仓库:<br />`$ git commit -m "resolve the conflict"`<br />`[apache-master 6ad2d5e] resolve the conflict`

Step 2 : Merge the changes and update on GitHub.

  • git checkout main

    1. # 将B切换为main<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/1240869/1610441379726-635b3b5b-2fc1-419b-98c2-5bdfb09ab0f0.png#height=70&id=hHs0O&margin=%5Bobject%20Object%5D&name=image.png&originHeight=70&originWidth=673&originalType=binary&ratio=1&size=10521&status=done&style=none&width=673)
  • git merge --no-ff JunzhouLiu-main

    1. #将B仓库的JunzhouLiu-main合入 main<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/1240869/1610442084826-fb22574b-e566-4516-b7fc-61396bd40e10.png#height=747&id=yH6qM&margin=%5Bobject%20Object%5D&name=image.png&originHeight=747&originWidth=825&originalType=binary&ratio=1&size=128675&status=done&style=none&width=825)
  • git push origin main

    1. #将B仓库的最终的本地库推到云端master<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/1240869/1610442100535-72233915-71f9-482e-a284-a925f10d56d6.png#height=224&id=i6ZZn&margin=%5Bobject%20Object%5D&name=image.png&originHeight=224&originWidth=710&originalType=binary&ratio=1&size=40668&status=done&style=none&width=710)

注意:删除冲突文件最好在合并前做,如果在合并后做且后续需要相关文件的话就需要重新添加相关文件

参考

  1. github fork 别人的项目源作者更新后如何同步更新——CSDN
  2. This branch has conflicts that must be resolved 解决示例——博客
  3. GitHub Desktop 安装和使用(附:百度云下载地址,永久有效)——CSDN
  4. github网站介绍、并使用git命令管理github(详细描述)——博客
  5. windows常用cmd命令——CSDN
  6. This branch has conflicts that must be resolved 解决示例)——博客
  7. Gihub Learning Lab——Github官方
  8. About merge conflicts——Github Docs