我在Github上fork了一个仓库。现在,原始仓库有一些更新。我如何从原始仓库中拉取更改并保持同步?
如果我的源代码与原始源代码冲突,我有机会手动编辑吗?
编辑1:谢谢大家的帮助。我想我需要阅读文档 :)
在其他两个答案中没有明确说明的是,您无法直接从github上的原始项目合并到自己的分支中,您需要通过本地克隆来完成。
所以您需要将原始项目设置为远程(在Magnus Skog和CJlano的答案中称为upstream
),然后从该远程仓库拉取到自己的本地克隆,并使用您本地的更改解决任何合并冲突,最后将结果推送到您在github上的分支中。
git remote add upstream path/to/upstream/repo.git
git pull upstream master
Pull in upstream changes
If the original repo you forked your project from gets updated, you can add those updates to your fork by running the following code:
git fetch upstream # Fetches any new changes from the original repo git merge upstream/master # Merges any changes fetched into your working files
https://help.github.com/articles/syncing-a-fork
附注:同步您的分支(fork)仅更新您的存储库的本地副本;它不会更新GitHub上的存储库。
附注2:每个步骤的实际代码在起始处粘贴的链接中。