Sync GitHub Fork with Original Repo (not using command or bash)
Syncing fork is a nightmare. I tried to fix it using a sneaky way without using command or bash.
If you are new to git, you might have a hard time syncing your fork with the original repo. It's not easy for a beginner. It requires some long steps as explained in the official docs. But there is a better & sneaky way to do that using github.com itself. No need to touch command or bash.
If you prefer a video, You may watch it here or scroll below.
How to sync Github repo with original?
So, if I have forked a repo from GitHub and then made some changes, then whenever the original repo pushed an update, it's a pain in the * to sync with it. So let's see how I tackle this issue.
Step 1: Your forked repo
Once you open your forked repo, you can find a banner on top if there are any new updates available from your original repo. There would be an option to Pull Request.
Step 2: The Pull Request Problem
Click on the pull request button and it will take you to the original repo and GitHub will start a pull request on the original repo. This is exactly the opposite of what we want.
As you can see in the below screenshot, Gituhb took us to the original repo and asking us to open a pull request on the original repo. We want the original to sync with our forked repo.
This is currently not possible with the current UI because if we tried to change the base repository or head repository, it will change to compare branches only. See below GIF.
Step 3: The Sneaky way to tackle the issue
As you see above we can't really open a pull request in our repo from the original. So we can do this little hack to do that.
Here are how the URLs look like right now.
Original Repo URL
Forked Repo URL
Github Compare & Pull Request URL
Now, here's the trick.
Replace the first part of the Compare and Pull Request URL with your Forked repo URL.
// Before https://github.com/mikecao/umami/compare/main...surjithctly:main // After https://github.com/surjithctly/web3analytics/compare/main...surjithctly:main
Now, change your username in the last part with the original repo Author.
// Before https://github.com/surjithctly/web3analytics/compare/main...surjithctly:main // After https://github.com/surjithctly/web3analytics/compare/main...mikecao:main
Now our Final URL looks like this:
mainif your repo is created before new github changes.
Step 4: Final Step
Now, visit the URL and if everything is correctly followed, you will see a compare & pull request page on your forked repo. Like the image below:
Now, you can click on the Pull Request button as usual. It will open a new pull request on your fork. If there are no conflict, it can merge automatically.
You are done!
That's all folks. How do you sync your repos? Do you have any good alternative way to do this fast? Let me know in the comments.