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
- Go to this URL: https://github.com/$my_username/$repo_name/compare/$branch_name...$origin_fork:$branch_name
- Click on "Create pull request"
- Add a title. I'd just call it
upstream sync, personally
- Click on the new "Create pull request" button
- Scroll to the bottom
- 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
- From your fork's repo, click on "New pull request"
- Click on "compare across forks"
- On the left-hand side, select your fork
- Click on "compare across forks" again
- On the right-hand side, select the origin fork
- 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: