Skip to content

Instantly share code, notes, and snippets.

@purveshmakode24
Last active October 7, 2020 08:52
Show Gist options
  • Save purveshmakode24/99f052732ec13e70806f09b80d259ec9 to your computer and use it in GitHub Desktop.
Save purveshmakode24/99f052732ec13e70806f09b80d259ec9 to your computer and use it in GitHub Desktop.
General instruction: Keeping fork upto date

Keep Your fork Upto Date.

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

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

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream

3. Updating your fork from original repo to keep up with their changes:

git pull upstream master

4. Push all the changes from Local to Remote:

git push origin master

Official Github Reference for Syncing a Fork


Important Tips

Best-Practices while working with the forked repository:

  1. If you want to make some changes into an app, prefer to create feature branches. i.e., Instead of making changes into your forked master-branch, make changes into your feature-branch.

  2. Keep your remote/local forked master-branch synchronized before creating any Feature-Branch. (This hardly gives you any merged conflicts when you make a pull request, unless if other user is making the same changes you are making after your remote/local forked master-branch synchronized with original branch.)

    If that's the case (Got any merge conflicts), you can simply resolve it by removing your conflict code from the feature-branch)

    Syncing Your GitHub Repo Reduces the Chances of a Merge Conflict

    • A merge conflict occurs when two people edit the same line in a file. Git does not know how to resolve the conflict (i.e. which changes to keep and which to remove).
    • When git does not know how to resolve a conflict, it will ask you to manually fix the conflict. If you sync your files regularly, you will ultimately reduce the risk of a merge conflict.
  3. Keep your local/remote forked master-branch synced with the original master-branch before making any pull requests.

    Original Master Branch: (Owner's/Upstream) master-branch from which you forked the repo.

Some other references to help you get started:

[IMP] How to review and edit a pull request:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment