git remote add upstream [email protected]:{fork origin accout name}/{repository name}.gitで fork 元のリポジトリを remote に追加する。git pull upstream masterで最新リポジトリを取得する。git pull upstream masterで fork 元の最新リポジトリを取得できるようになる。
リポジトリを fork した時、remote が以下のようになっている。
$ git remote -v
origin [email protected]:{forked accout name}/{repository name}.git (fetch)
origin [email protected]:{forked accout name}/{repository name}.git (push)
これでは git pull origin master としても fork 元の最新がとってこれないので、 git remote add upstream [email protected]:{fork origin accout name}/{repository name}.git とし、remote に fork 元のリポジトリを追加してやる。
そうしてから、remote を確認したら以下のようになる。
$ git remote -v
origin [email protected]:{forked accout name}/{repository name}.git (fetch)
origin [email protected]:{forked accout name}/{repository name}.git (push)
upstream [email protected]:{fork origin accout name}/{repository name}.git (fetch)
upstream [email protected]:{fork origin accout name}/{repository name}.git (push)
これでリポジトリの最新を取ってくるのは git pull upstream master で済む。