Skip to content

Update a Github Fork from the Original Repo

jessica-wang edited this page May 17, 2012 · 19 revisions

(Had to use "1_ ", "2_ " instead of "1.", "2." because of the messy ordered list)

The original article is here: http://bradlyfeeley.com/2008/09/03/update-a-github-fork-from-the-original-repo/

There's also a post in stackoverflow: http://stackoverflow.com/questions/7244321/how-to-update-github-forked-repository

The following is commands using our names, e.g. Polonious, Regimo, etc.

To update your local repository with changes in the central repository,

1_ Go to the relevant workspace: [your_workspace]/Regimo (if there is a "Regimo" don't forget to add it)

2_ Add a remote branch to your repository that points to the original repo you forked from.

git remote add --track master [remote_branch] git://github.com/Polonious/Regimo.git

3_ To verify the remote repository was added run

git remote

You should see the new remote repo [remote_branch] along with any other remote repositories you may have previously added.

4_ Now we can fetch all the changes from [remote_branch]’s code base.

git fetch [remote_branch]

This will create a new remote branch called "[remote_branch]/master".

5_ Now we are ready to merge the code from the remote repository.

git merge [remote_branch]/master

That’s it. The project on your local machine will be updated to the latest in the central repository.

Remember, this process isn’t limited only to the original repository. Feel free to add remote branches for other user’s forks or even from repositories outside Github.

You don't need to add a new [remote_branch] every time you do an update. If the [remote_branch] is already there, you can start from Step 3 or 4.

Clone this wiki locally