Thursday, 16 November 2017

Github: How to keep Your Forked Repo Up-to-Date?

Sometimes, when we don't have "write" access to your working repository, we cannot create a new branch to apply your changes or we cannot push our changes to master.

We cannot create PR (Pull Request) to review your changes by peers.

In this case, we cannot use "Cloning", should use "Forking" concept.

Github Forking:

Forking is different from Cloning. Login to your profile and click on "Forking" button or link available at top right corner.

It creates same repository into your github profile. Then fork it and work on changes.

Now we don't need to create a Branch as we are working on forked repository.

Just pull your changes to your forked master:   

$ git pull

Forking Problem:

Above procedure works as long as you don't see the following message:


Lets us ORIGINAL_REPO  is main repository and FORKED_REPO is our forked repo created from ORIGINAL_REPO.

1. Clone your fork:

git clone<user-name>/FORKED_REPO.git

2. Add remote from original repository in your forked repository:

git remote add upstream git://<user-name>/ORIGINAL_REPO.git
git fetch upstream

3. Updating your fork from original repository to keep up-to-date changes:

git pull upstream master

4. Push changes to your forked repository:
git push

Thank you 

No comments:

Post a Comment