首次fork
具体步骤:
- 进入自己fork它人项目的界面,点击【Pull request】
- 在进入的界面中,右边改为被fork的项目,左边改为自己需要更新的fork过来的项目
- 出现变更的文件后点击点击【create pull request】
- 随后点击【Merage pull request】
多次更新fork后出现【This branch has conflicts that must be resolved】冲突提示
需要工具:GitHub Desktop、Git
具体步骤:
- 下载并安装好GitHub Desktop后clone自己想要解决冲突的项目文件到本地[3]
- 下载并安装好Git后[4],通过cmd进入上一步中clone的本地项目根目录[5]
cd /d C:\Users\yinian\Documents\Github\BILIBILI-HELPER
随后使用如下git命令
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
#建立B的JunzhouLiu-main分支,并切换到JunzhouLiu-main<br />
git pull git://github.com/JunzhouLiu/BILIBILI-HELPER.git main
#将A最新的内容合入JunzhouLiu-main<br /> #因为有冲突,所以上条执行时,会提示冲突:<br />
手动打开冲突文件,根据提示修改,删除冲突的内容,留下想要的结果内容。
#修改后注意在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
# 将B切换为main<br />
git merge --no-ff JunzhouLiu-main
#将B仓库的JunzhouLiu-main合入 main<br />
git push origin main
#将B仓库的最终的本地库推到云端master<br />
注意:删除冲突文件最好在合并前做,如果在合并后做且后续需要相关文件的话就需要重新添加相关文件
参考
- github fork 别人的项目源作者更新后如何同步更新——CSDN
- This branch has conflicts that must be resolved 解决示例——博客
- GitHub Desktop 安装和使用(附:百度云下载地址,永久有效)——CSDN
- github网站介绍、并使用git命令管理github(详细描述)——博客
- windows常用cmd命令——CSDN
- This branch has conflicts that must be resolved 解决示例)——博客
- Gihub Learning Lab——Github官方
- About merge conflicts——Github Docs