One interesting thing I learnt about git is that its possible to have multiple
remotes connected to a local repo.
Here’s how to do it(assuming
origin is your fork of the repo)
## add a remote called upstream which is an alias to the parent repo
git remote add upstream https://path/to/the/parent/repo
## update your local repo with upstream changes
git pull upstream branch-name
git push origin branch-name
I’ve done this for Events plugin and it saves me a lot of hassle.
It’s useful, I do it all the time, but that’s not really ‘switching between forks’ though, is it?
You are merely pulling in the parent updates of branch-name to local and then pushing to your forks’ branch?
Your local still remains (say) a clone of your chosen fork?
What if you want to work directly on the upstream fork?
If you have the rights to push upstream. You can.
Now that is useful.
Although generally you’d want to raise a PR?
Yeah. Thats the case most of the time.
upstream are simply aliases and the tool doesn’t make an assumption on how the user chooses to use it. Its generally fun when we finally understand the
underlying principles behind something and get to be called experienced in a discipline.
git is amazing.
The guy should get some kind of knighthood!
Yeah. Remember, the same guy wrote linux though. Git would be nothing for him compared to linux. He designed it in 1 month’s time.
And interestingly, he wrote it to manage linux code.