2012-08-09 119 views
9

我已经分叉了一个git回购。 如果源有更新,分叉的回购是否自动更新? 或者我应该在cmd中执行一些命令来更新此分叉回购? 这是什么命令?如何更新分叉的git回购?

回答

0

当一个repo被克隆时,它有一个默认的远程调用origin,它指向您在GitHub上的fork,而不是它从其分出的原始repo。为了跟踪原有回购的,你需要添加另一个远程上游命名为:

当他们在这个Blog Post说。

17

他们对GitHub的文档这个话题非常具体的帮助:https://help.github.com/articles/fork-a-repo

配置远程数据库

当回购被克隆,它有一个默认的远程叫产地证明 点到你的叉子上GitHub,而不是它原来的分销商 。为了保持原有回购的轨道,你需要添加另一个 远程上游命名为:

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 

上游拉改变

如果分叉项目原来的回购从得到更新,你

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

git merge upstream/master 
# Merges any changes fetched into your working files 
: 可以通过运行下面的代码添加这些更新到你的叉子