
Introduction
When collaborating with github projects, normally, you do your changes in your fork / branch and then push these changes to your origin ( and when you create a PR it should automatically point to original repo master ). Recently I started collaborating with a github project called excalidraw and they use that approach. Even if that sounds a easy thing to do, it is not, specially new developers could struggle to get sync done for first time.
Sync Fork with Original Repo
Best and quicker approach to sync your repo is:
Let’s explain the approach:
Configure
upstream
We should have
origin: <our fork url>
andupstream: <original repo url>
. If we don’t haveupstream
configured then we should add it.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15git remote -v
origin https://github.com/jquintozamora/excalidraw.git (fetch)
origin https://github.com/jquintozamora/excalidraw.git (push)
git remote add upstream https://github.com/excalidraw/excalidraw.git
git remote -v
origin https://github.com/jquintozamora/excalidraw.git (fetch)
origin https://github.com/jquintozamora/excalidraw.git (push)
upstream https://github.com/excalidraw/excalidraw.git (fetch)
upstream https://github.com/excalidraw/excalidraw.git (push)We should now see both
origin
andupstream
setup properly done.fetch
changes from original repo ( upstream ) ⬇️1
2
3
4
5
6
7
8git fetch upstream -ap
remote: Enumerating objects: 286, done.
remote: Counting objects: 100% (286/286), done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 322 (delta 249), reused 241 (delta 220), pack-reused 36
Receiving objects: 100% (322/322), 125.10 KiB | 1.03 MiB/s, done.
...merge
changes from upstream into your fork 🔄1
2
3
4
5git merge upstream/master
Updating 6635261..ae1eee1
Fast-forward
changes...After merge, we will have both repos on sync on our local machine. But, I’d recommend to push changes to have your fork updated on github too.
push
to sync changes on github too ⬆️1
2
3
4
5git push origin master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/jquintozamora/excalidraw.git
6635261..ae1eee1 master -> master
🚀🚀 DONE 🚀🚀
I hope it works for you as well, if have any issues, please leave a comment, so we can discuss and try to help!