简体   繁体   中英

Push existing git repo to new branch of different repo

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.

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.

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.

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM