It is a common situation when we fork a project on Github and after some time we want to update our fork with the changes that have been integrated into the source project from where we forked. This is a simple guide on how to do that.
Conditions:
- We have the
remoteof source project added to our local git repo. - The name of the source project remote is
upstream. - We are syncing changes from
upstream/masterto our localmasterbranch.
Below are the steps I found on Github’s guide.
- Commit/Stash all your local changes.
- Checkout your local
masterbranch if not already there.git checkout master - Fetch (not pull) changes from
upstream.git fetch upstream - Merge changes from
upstream/masterto localmaster.git merge upstream/master - Resolve merge-conflicts, if any.
And you are done. Your local master branch is now updated with changes from upstream/master.
Source: Github guide
Tip: Syncing like this will only update your local master. You will still need to push those synced changes to your Github repo if you want to update that too.
This was just a quick tip that I needed quite a lot recently and every time I had to go and search for that guide. So I wrote this to solidify the concepts in my mind. If you have any more such tips I would love to hear about them at this @varun_barad.
Top comments (0)