[GitHub] How to Sync a Forked Repository with the Original Repository
I’ll introduce the procedure for syncing a forked repository on GitHub to follow the original repository.
 
We assume you’ve already forked some repository on GitHub.
First, git clone the forked repository.
git clone [email protected]:your_account/sample_repository.git
Set the original repository you forked from as a remote repository with the name “upstream”.
git remote add upstream git://github.com/original_account/sample_repository.git
From now on, you can handle the original forked repository with the name “upstream”.
You only need to set this up once initially; no reconfiguration is needed.
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/upstream/master
$ git fetch upstream
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 1 (delta 0)
Unpacking objects: 100% (1/1), done.
From git://github.com/original_account/sample_repository
 * [new branch]      develop    -> upstream/develop
 * [new branch]      master     -> upstream/master
Merge the differences obtained with git fetch into the current branch.
$ git merge upstream/master
Updating 1e579f8..21e70ae
Fast-forward
For those unfamiliar with OSS development, working with forked repositories on GitHub and syncing with the original branch is probably uncommon, so I hope this article helps even a little.
That’s all from the Gemba.