How can I Resync a fork from original
By design, forking a project creates a separate repo that is not updated when the original repo changes. However, git
makes it pretty easy to update manually.
You need the help of a 3rd repository (your local copy suffices). There are 3 repos:
- "Upstream": The upstream project's repository on Github.
- "Origin": Your fork's repository on Github
- "Local": Your local repository on your computer. I will assume you created it by cloning Fork using
git clone [email protected]:your-username/projectname.git
, and that everyone is using branchmaster
.
Assuming currently "Origin" and "Local" are in the same state, and "Upstream" is ahead by 1 or more commits (the merge and any subsequent changes).
First add the upstream project as a Git remote:
git remote add upstream https://github.com/upstream-username/projectname.git
Then pull (meaning fetch and then merge automatically) the changes from the remote's master
branch into your local repository's current (master
) branch:
git pull upstream master
Now your local repository is in sync with upstream
. Finally, push your local repo to your Github fork:
git push origin master
Now everything is in sync.