How to Update a Fork in Git

sunil kumar sahoo
2 min readDec 2, 2019

--

Git fork work flow

How to Update a Fork in Github

  1. Access your forked repository on Github.
  2. Click “Pull Requests” on the right, then click the “New Pull Request” button.
  3. 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”.
  4. Click “Create Pull Request”, give it a name, click “Send Pull Request”.
  5. 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)

  1. Verify the remote branch attached for fetch and push operation using following command git remote -v
  2. Specify a remote upstream repo to sync with your fork git remote add upstream https://github.com/OriginalRepo/OriginalProject.git
  3. Verify using git remote -v
  4. Fetch branches and commits from the upstream repo. You’ll be storing the commits to master in a local branch upstream/master using following commandgit fetch upstream
  5. Checkout your fork’s local master using following commandgit checkout master
  6. Merge changes from upstream/master into it git merge upstream/master
  7. Push changes to update your fork master on Github git push origin master

--

--