If you are trying to figure out about github and the concepts behind it, you can easily get started by referring this tutorial.
most of the open source projects exist in the github. You can fork them in to your repository, modify them and you can commit the changes back to the origin repository. But while doing development, most of the folks forget to get sync with the latest commits from the upstream origin. Therefore, this blog post describes about how to sync the forked repository with upstream repository.
If you have just cloned the forked out repository from origin or if you haven't added the remote upstream repository, then you have to follow the steps #1-#4.
#1
If you haven't cloned the forked repository, you have to start the proceedings by cloning the forked repository.
List the currently configured remote repository with forked one.
git clone https://github.com/firzhan/carbon-registry.git
#2
Check the currently configured remote repository.
git remote -v
#3
Specify the upstream repository that
will be synced with forked repository.
git remote add upstream https://github.com/wso2/carbon-registry.git
#4
Verify the upstream repository and origin by checking the remote URLs.
git remote -v
The tasks #1 to #4 are one time task. You have to do them when you cloned a forked repository.
Rest of the tasks should be done when ever you are trying to push changes to the forked master branch. By making this as a habit you can avoid unnecessary conflicts which may arise when merging pull requests.
#5
Fetch all the commits from upstream
repository.
git fetch upstream
#6
Now checkout the master and merge it
with the upstreams master.
git checkout master
git merge upstream/master
If the upstream had changes, git will be printing out the summary on current updates.
Now you are having an updated repository.
In additionally you can check the difference between upstream and local repo using following command
In additionally you can check the difference between upstream and local repo using following command
git diff master upstream/master > bps.diff
No comments:
Post a Comment