Pages

Wednesday, October 8, 2014

Synchronize forked repository with new commits to original repository

To synchronize with your forked repository with the new updated content of the original repository follow these 5 steps:

Step 1
Check whether that you have configured a remote to original repository
git remote -v  command will list remote URLs as follows

If you haven't configured remote to original repository, you will see only origin (which is forked your repository) in the list. 

Step 2
configure a remote pointing original repository with following command
git remote add <remote_name> <url>
Generally we use name "upstream"
then list down remotes and check whether upstream is in the list

Step 3
Now download content from the original repository using fetch command
git fetch <remote>
This will fetch all the branches and commits from the original repository (if <remote> is pointing to it), in this case upstream

Step 4
Check out your local master branch by git checkout master command. 
At this point you have to commit if you have done any changes to local repository.

Step 5
Now merge changes from upstream master to local master by following command
git merge upstream/master
you will see similar to following

Now you local repository is updated with original repository's new content.

Then you can push new updates to your remote repository

Cheers ....

No comments:

Post a Comment