I have created a branch in my GitHub repo: https://github.com/markmnl/FalconUDP, so there are now two branches: "master" and "single-threaded". I realise now I will never want to merge "single-threaded" back into "master" and want to maintain each branch separately independently of one another, though from time-to-time I will want to cherry pick bits of code from one into the other.
It would be disastrous should the branches be accidentally merged (though not catastrophic of course since I can always go back - it being in source control).
It strikes me what I should have done is fork the project into another repo. (That way I can still do the cherry picking with Pull Requests).
What should I do now?
In github (and in git's mental framework) you clone and fork repositories. There's no way to fork a branch; that doesn't make sense. Just fork the project, and work off the branch you're interested in.
So, unlike a branch, a fork is independent from the original repository. If the original repository is deleted, the fork remains. If you fork a repository, you get that repository and all of its branches.
If you need to fork a GitHub or GitLab repo, it's as simple as navigating to the landing page of the repository in your web browser and clicking on the Fork button on the repository's home page. A forked copy of that Git repository will be added to your personal GitHub or GitLab repo. That's it.
On GitHub, navigate to the main page of the forked repository that you want to sync with the upstream repository. Select the Sync fork dropdown. Review the details about the commits from the upstream repository, then click Update branch.
If I understand correctly, you want to create a fork a project within the same user account or organization in GitHub. This seems explicitly unsupported by GitHub, explained their article Alternatives to forking into the same account.
Something you can do, and might be suitable for your purpose, is create a new repository and push the single-threaded
branch to it:
Create new repo, completely empty (do NOT add README or other files): https://github.com/new
In your local clone of the original repo, add the new repo as a new remote, let's call this remote repo2
for example:
git remote add repo2 NEW_REPO_URL
Push your single-threaded
branch to the new repo (repo2
remote):
git push -u repo2 single-threaded
Delete this branch from the original project, assuming your remote is called origin
:
git push origin :single-threaded
This is not the same thing as the fork feature on GitHub.
The fork feature on GitHub would show on the UI of repo2
a link to the original repo. According to the article I linked above, I think you cannot have that effect. If you want to bring attention to the existence of these two repos, and how to use them, I think your best option is to document it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With