Another Japan in the World

Jun Aruga's blog, who lived in Japan, Singapore, live in Czech Republic. Mainly about IT and travel.

How to synchronize your forked repository

Synchronize your repository forked from other upstream repository, with the upstream repository.

For example,

I forked from https://github.com/sideshowcoder/localmemcache .
My forked repository is https://github.com/junaruga/localmemcache .

I want to synchronize https://github.com/sideshowcoder/localmemcache 's modification.
How?

$ cd $GIT_DIR/localmemcache
$ git remote -v
origin	https://github.com/junaruga/localmemcache.git (fetch)
origin	https://github.com/junaruga/localmemcache.git (push)

Add the repository: https://github.com/sideshowcoder/localmemcache as "upstream".

$ git remote add upstream https://github.com/sideshowcoder/localmemcache.git
$ git remote -v
origin	https://github.com/junaruga/localmemcache.git (fetch)
origin	https://github.com/junaruga/localmemcache.git (push)
upstream	https://github.com/sideshowcoder/localmemcache.git (fetch)
upstream	https://github.com/sideshowcoder/localmemcache.git (push)

Get latest modification from the upstream repository's master branch.
You can see the local source is updated.

$ git pull upstream master

$ git log

Finally to synchronize your github repository with upstream repository.

$ git push origin master

That's all.

Remove all ads