将现有的git repo推送到不同repo的新分支

时间:2021-02-20 16:24:17

I'm using git-tfs to migrate repositories, and due to a quirk of the tool I have to clone/convert a branch to its own repo. How can I push this separate repo, which has its own history and everything, to a branch of an existing repo? I can start from scratch and try to push everything at once if that's easier.

我正在使用git-tfs来迁移存储库,由于工具的怪癖,我必须将分支克隆/转换为自己的存储库。我怎样才能将这个拥有自己的历史和所有内容的独立仓库推送到现有仓库的一个分支?如果这更容易,我可以从头开始尝试一次推送所有内容。

1 个解决方案

#1


0  

sidenote: Taking your question directly - From a repository you can only push X (1,2,3,4,...x) branches to another repository which will get them as X (1,2,3,4,...x) braches. You can't put a "whole repository" as a 1 branch into another one. Well, unless you build something like that with submodules. Check them out later, maybe you will find that useful.

旁注:直接提出您的问题 - 从存储库中您只能将X(1,2,3,4,... x)分支推送到另一个存储库,这将使它们成为X(1,2,3,4,... .x)braches。您不能将“整个存储库”作为1分支放入另一个分支。好吧,除非你用子模块构建类似的东西。稍后再查看它们,也许你会发现它很有用。

To solve your git-tfs workflow - I think you actually want to push one specific branch from that side-repo to your main-repo. Say, "master" from side-repo -> "issue-273-fixing-labels" in main-repo. That should be quite easy if you really clone'd it.

为了解决你的git-tfs工作流程 - 我认为你实际上想要将一个特定的分支从那个副目录推送到你的主仓库。在主回购中说,来自side-repo的“master” - >“issue-273-fixing-labels”。如果你真的克隆它,那应该很容易。

Cloneing has a sideeffect of setting up an origin URL for you, so the command would be something like:

克隆具有为您设置原始URL的副作用,因此命令将类似于:

cd ../../siderepo
git push origin master:issue-273-fixing-labels

note the 'origin' is a typical name for a remote that points to main-repo (that part should be set by cloning, if not then do `git remote add origin {here PATH or URL to mainrepo}). "master" is the source branch from side-repo, "issue-273-fixing-labels" is the target branch in main-repo.

请注意,'origin'是指向main-repo的遥控器的典型名称(该部分应通过克隆设置,否则请执行`git remote add origin {此处为PATH或URL to mainrepo})。 “master”是来自side-repo的源分支,“issue-273-fixing-labels”是main-repo中的目标分支。

substitute origin, master and issue-273-fixing-labels as you need.

根据需要替换原产地,主人和发行标签。

#1


0  

sidenote: Taking your question directly - From a repository you can only push X (1,2,3,4,...x) branches to another repository which will get them as X (1,2,3,4,...x) braches. You can't put a "whole repository" as a 1 branch into another one. Well, unless you build something like that with submodules. Check them out later, maybe you will find that useful.

旁注:直接提出您的问题 - 从存储库中您只能将X(1,2,3,4,... x)分支推送到另一个存储库,这将使它们成为X(1,2,3,4,... .x)braches。您不能将“整个存储库”作为1分支放入另一个分支。好吧,除非你用子模块构建类似的东西。稍后再查看它们,也许你会发现它很有用。

To solve your git-tfs workflow - I think you actually want to push one specific branch from that side-repo to your main-repo. Say, "master" from side-repo -> "issue-273-fixing-labels" in main-repo. That should be quite easy if you really clone'd it.

为了解决你的git-tfs工作流程 - 我认为你实际上想要将一个特定的分支从那个副目录推送到你的主仓库。在主回购中说,来自side-repo的“master” - >“issue-273-fixing-labels”。如果你真的克隆它,那应该很容易。

Cloneing has a sideeffect of setting up an origin URL for you, so the command would be something like:

克隆具有为您设置原始URL的副作用,因此命令将类似于:

cd ../../siderepo
git push origin master:issue-273-fixing-labels

note the 'origin' is a typical name for a remote that points to main-repo (that part should be set by cloning, if not then do `git remote add origin {here PATH or URL to mainrepo}). "master" is the source branch from side-repo, "issue-273-fixing-labels" is the target branch in main-repo.

请注意,'origin'是指向main-repo的遥控器的典型名称(该部分应通过克隆设置,否则请执行`git remote add origin {此处为PATH或URL to mainrepo})。 “master”是来自side-repo的源分支,“issue-273-fixing-labels”是main-repo中的目标分支。

substitute origin, master and issue-273-fixing-labels as you need.

根据需要替换原产地,主人和发行标签。