Skip to content

Instantly share code, notes, and snippets.

@jorgecasariego
Last active August 1, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgecasariego/37cda0cbaee1cea33ccd99a7876ec15e to your computer and use it in GitHub Desktop.
Save jorgecasariego/37cda0cbaee1cea33ccd99a7876ec15e to your computer and use it in GitHub Desktop.
Keeping a fork up to 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. Make sure that you're on your master branch:

git checkout master

4. Update your fork from original repo to keep up with their changes:

git pull upstream master

5. Rewrite your master branch:

So that any commits of yours that aren't already in upstream/master are replayed on top of that other branch:

git rebase upstream/master

6. Force the push in order to push it to your own forked repository:

If you've rebased your branch onto upstream/master you may need to on GitHub. You'd do that with:

git push -f origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment