Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fetch Upstream Changes to your personal Fork from the original repo for HTTPS
Original write-up Gist for SSH: https://gist.github.com/CristinaSolana/1885435

HTTPS Instructions

Command-line Instructions

1. Clone your fork:

git clone https://github.com/$my_username/$repo_name

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

cd $repo_name
git remote add upstream https://github.com/$origin_fork/$repo_name.git
git fetch upstream

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

git pull upstream $branch_name

Real Example for command-line

You'll need to fork pandas-dev/pandas if you want to follow along. I'm not associated with them; I just chose a random repo I already had forked from the front-page.

git clone https://github.com/pandas-dev/pandas
cd pandas
git remote add upstream https://github.com/pandas-dev/pandas.git
git fetch upstream
git checkout master
git pull upstream master
git add -A
git commit -m "Sync my pandas master w/ pandas-dev master branch"
git push origin master

Browser Instructions

  1. Go to this URL: https://github.com/$my_username/$repo_name/compare/$branch_name...$origin_fork:$branch_name
  2. Click on "Create pull request"
  3. Add a title. I'd just call it upstream sync, personally
  4. Click on the new "Create pull request" button
  5. Scroll to the bottom
  6. Merge the pull request
    a. If you want to keep the commit history, just click "Merge pull request", then "Confirm merge"
    b. If you just want the code changes and only have a single commit to merge, click on the dropdown for "Merge pull request", select "Squash and Merge", then click on "Confirm Squash and Merge" c. If you want to rebase, have fun with that :) jk! Do pretty much the same thing as 6b but use the Rebase options

Alternative browser instructions

  1. From your fork's repo, click on "New pull request"
  2. Click on "compare across forks"
  3. On the left-hand side, select your fork
  4. Click on "compare across forks" again
  5. On the right-hand side, select the origin fork
  6. Follow steps #2 through #6 in the Browser Instructions section above this one

Real example for browser

While I can't really give you a "real" example for this beyond a screenshot, here's what I used for Mozilla's DeepSpeech sync to master:

https://github.com/the-nose-knows/DeepSpeech/compare/master...mozilla:master

browser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.