24.7.15

Github : You don't need more than one fork

I recently ran into an issue where someone in my organization had a highly specified fork of an upstream repository, and I first thought: Damn, this person stole my fork and now i can't use it !

So, I needed "my own fork", but under the same repository - I wanted github to perceive the fork as a true fork of a repository, for the sake of pull requests and so on.

So, here's the trick.

THERE IS NO TRICK.

You don't need to worry ! Remember, in git, you can have a branch which comes from ANY remote, so your branch in a fork need not share any history with the other evil fork that you hate.  Just live in the same repo on a branch with no shared lineage.

How?

Its so easy its almost easy to overlook.  But heres how you do it.

git remote add MY_FORK git@github.com:roofmonkey/already-forked-repo.git

Now checkout the remote you like:

git checkout -b UPSTREAM/master

Now branch from it

git checkout -b SCALE_HA

Now push your master based branch to git

git push MY_FORK SCALE_HA


Now you have your own dev branch in the same fork, with no shared history with other forks master.

So no need to fork twice.

No comments:

Post a Comment