How to Update a Fork in Git
2 min readDec 2, 2019
How to Update a Fork in Github
- Access your forked repository on Github.
- Click “Pull Requests” on the right, then click the “New Pull Request” button.
- Github first compares the base fork with yours, and will find nothing if you made no changes, so, click “switching the base”, which will change your fork to the base, and the original to the head fork. Now you should see changes where your fork needs to play “catch up”.
- Click “Create Pull Request”, give it a name, click “Send Pull Request”.
- Click “Merge Pull Request” and “Confirm Merge”.
Assuming you had no changes, you can then merge automatically.
How to Update a Local Fork at the Terminal/Command Line Interface(CLI)
- Verify the remote branch attached for fetch and push operation using following command
git remote -v
- Specify a remote upstream repo to sync with your fork
git remote add upstream https://github.com/OriginalRepo/OriginalProject.git
- Verify using
git remote -v
- Fetch branches and commits from the upstream repo. You’ll be storing the commits to master in a local branch upstream/master using following command
git fetch upstream
- Checkout your fork’s local master using following command
git checkout master
- Merge changes from upstream/master into it
git merge upstream/master
- Push changes to update your fork master on Github
git push origin master