很多人都fork过,此时若是源仓库(你fork的那个仓库)有了新的提交,此时如何把新的提交也同步的fork过来?
这里有github的原文,可以直接看。也可以往下看
[Syncing a fork]: https://help.github.com/en/articles/syncing-a-fork
注:先把fork的仓库clone到你本地。下面的都是基于本地仓库操作的!
$ git remote -v
> origin https://github.com/YOUR_USERNAME/你的fork仓库.git (fetch)
> origin https://github.com/YOUR_USERNAME/你的fork仓库.git (push)
$ git remote add upstream https://github.com/ORIGINAL_OWNER/源仓库.git
$ git remote -v
> origin https://github.com/YOUR_USERNAME/你的fork仓库.git (fetch)
> origin https://github.com/YOUR_USERNAME/你的fork仓库.git (push)
> upstream https://github.com/ORIGINAL_OWNER/源仓库.git (fetch)
> upstream https://github.com/ORIGINAL_OWNER/源仓库.git (push)
$ git fetch upstream
> remote: Counting objects: 75, done.
> remote: Compressing objects: 100% (53/53), done.
> remote: Total 62 (delta 27), reused 44 (delta 9)
> Unpacking objects: 100% (62/62), done.
> From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY> * [new branch] master -> upstream/master
$ git checkout master
> Switched to branch 'master'
$ git merge upstream/master
> Updating a422352..5fdff0f
> Fast-forward
> README | 9 -------
> README.md | 7 ++++++
> 2 files changed, 7 insertions(+), 9 deletions(-)
> delete mode 100644 README
> create mode 100644 README.md
通过这个也要反思一下。很早之前我就会fork别人的仓库,但是别人整个仓库的内容,并不是fork一下就全学会了的。
原文:https://www.cnblogs.com/Mr-O-O/p/11668464.html