How to update forked repository from original repository

This article, I’ll describe how to update your fork repository on Github.
very simple way.

First thing, you have to copy original repository URL.
You can get from Clone or download button.

Capture git clone

Then, use bellow git command in your local repository, and you set remote repository.
In this case, named upstream, you have to name other than origin.

$ git remote add upstream <Oiginal repository URL>

Please, check remote infomation.

$ git remote -v

If it added upstream remote, you are sccuesss.
You can pull from original repository. The bellow command is to get updated data from original repository.

$ git pull upstream <branch name>

branch name like a master.

Finaly, let’s push to a forked remote repository.

$ git push origin master

That’s it.

関連記事