如何更新分叉git仓库?

Liz*_*ith 9 git github git-fork

我已经分享了一个git repo.如果原点有更新,forked repo会自动更新吗?或者我应该在cmd中执行一些命令来更新此分叉存储库?这个命令是什么?

jdi*_*jdi 19

他们在github文档上对此主题有非常具体的帮助:https://help.github.com/articles/fork-a-repo

配置遥控器

当一个repo被克隆时,它有一个默认的远程名为origin,指向你在GitHub上的fork,而不是它分叉的原始repo.要跟踪原始仓库,您需要添加另一个名为upstream的远程:

git remote add upstream https://github.com/octocat/Spoon-Knife.git
# Assigns the original repo to a remote called "upstream"

git fetch upstream
# Pulls in changes not present in your local repository, 
# without modifying your files
Run Code Online (Sandbox Code Playgroud)

拉入上游变化

如果您分割项目的原始仓库已更新,则可以通过运行以下代码将这些更新添加到fork中:

git fetch upstream
# Fetches any new changes from the original repo

git merge upstream/master
# Merges any changes fetched into your working files
Run Code Online (Sandbox Code Playgroud)


ntr*_*trp 0

克隆存储库时,它有一个名为 origin 的默认远程存储库,该存储库指向您在 GitHub 上的分支,而不是它派生的原始存储库。要跟踪原始存储库,您需要添加另一个名为上游的远程:

正如他们在这篇博客文章中所说的那样。