如何把一个git分支变成fork? [英] How to turn a git branch into fork?
问题描述
我在GitHub repo中创建了一个分支: https://github.com/markmnl/FalconUDP,所以现在有两个分支:主和单线程。我意识到现在我永远不会想要将单线程合并回主,并且希望分别独立维护每个分支,但是不时地我会希望从一个代码中挑选一些代码另一方面。
如果分支意外合并(当然不是灾难性的,因为我总是可以返回 - 它是在源代码控制中)会是灾难性的。
这让我感到我应该做的就是将该项目分成另一个回购。 (这样我仍然可以用Pull Request做樱桃采摘)。
我现在该做什么?
我想你的问题具体是:如何在GitHub中的相同用户帐户中创建自己项目的分支。您不能使用网站的用户界面,但您可以创建一个新的存储库并将相关分支推送给它:创建新的回购,完全空白,甚至没有自述文件 https://github.com/new
在原始项目的本地克隆中添加新的回购作为新的远程,例如,我们称这个远程 fork
为例:
git remote add fork NEW_REPO_URL
将您的单线程
分支推送到它:
git push -u fork单线程
假设你的远程被称为 origin
:
git push origin:单线程
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?
I guess your question is specifically: how to create a fork of your own project in the same user account in GitHub. You cannot use the user interface of the website, but you can create a new repository and push the relevant branches to it:
Create new repo, completely empty, without even a README https://github.com/new
Add the new repo as a new remote in your local clone of the original project, let's call this remote
fork
for example:git remote add fork NEW_REPO_URL
Push your
single-threaded
branch to it:git push -u fork single-threaded
Delete this branch from the original project, assuming your remote is called
origin
:git push origin :single-threaded
这篇关于如何把一个git分支变成fork?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!