Copying some branches of a repository into a new repository

We have a huge git repository (say it A )that contains many branches. I want to create a new smaller repository (say it B) that will contain few branches of A.

What I know is as follows

  1. Clone some branches from repository A to local
  2. Push these branches to repository B.

Don’t we have some method to copy these branches directly from repository A to B?. Or some improvement to the above mthod?

  • How to manage backups and monitor Git with a central repository?
  • How to isolate projects/folders with git that are part of a large project?
  • When to use a Tag/Label and when to branch?
  • Not getting the coverage on new code in sonar dashboard
  • Create fast-export package from Mercurial repository
  • git merge pull request to private repository
  • MySQL versioning control to complement GIT?
  • Get commit history after date (since/after parameter)
  • One Solution collect form web for “Copying some branches of a repository into a new repository”

    If you have direct access to repo A, you can directly the branch you want to a new repo B.

    But if you need to clone A first, then a concrete example exists in “Clone just the stable and one other branch in git?”, and uses the same tip than the question mentioned by mnagel, with git remote:

     cd B
     git init .
     git remote add -f -t remote-branch1 -t remote-branch1 remote-name remote-url

    Note the -f which, when used with git remote add, will immediately fetch remote_name.

    Git Baby is a git and github fan, let's start git clone.