2012-08-09 121 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 
: 可以通過運行下面的代碼添加這些更新到你的叉子