Import all branches of one Git repository into another one

I have two git repositories. Both have a master branch that is manually kept in sync with a different branch of the same CVS repository, and a decent amount of feature branches.

For example

  • Branching with Mercurial SCM
  • When is the right time to delete a git feature branch?
  • How do I fetch a single branch using Git SVN fetch?
  • Remove inactive branches from IIS via TeamCity
  • In git is it possible to merge from the master to a branch that was originally created from master after new code has been added to the master?
  • git branch restoration after merge
    • Git repository OLD:
      • master (manually tracking the CVS branch OLD_VERSION)
      • feature-abc-backport
      • feature-xyz
    • Git repository CURRENT:
      • master (manually tracking HEAD of the CVS repository)
      • feature-abc
      • feature-123

    I now want to import all branches from OLD into CURRENT, with some prefix added (e.g. OLD-master, OLD-feature-abc-backport, OLD-feature-xyz). Is this possible?

  • Perforce, How to integrate a change to another branch?
  • Git: pre-receive hook to allow only merges and not direct commits into master
  • How to grep (search) committed code in the git history?
  • Git renaming file. History is available on cmd-line, but not in github interface?
  • Git reset changes from unstaged file
  • Continuous integration and continuous delivery with git-flow
  • One Solution collect form web for “Import all branches of one Git repository into another one”

    Importing a branch is possible.
    Manage it once imported can be trickier.

    Importing:

    cd current
    git remote add old /url/to/git/old
    git fetch old
    git branch --track old_master old/master
    git branch --track old_feature-abc-backport old/feature-abc-backport
    git branch --track old_feature-xyz old/feature-xyz
    

    Managing:

    The question is: are the commits of the git ‘old’ repos the same as the ones in the git ‘current’ repo?
    If yes, then you can merge an old_xxx branch in a current branch, since the delta would be limited.


    Actually, I would like to do the import mainly for archival purposes, at least in the first step. When a branch goes out of maintenance

    Then a simple fetch is enough:

    All the branches from old will be immediately references as old/abranch: no need to create a local branch with a ‘old_’ prefix.
    Their full history will be available in your current repo (after the fetch), and each old branch HEAD will be references by the remote tracking branches (created by the fetch) in refs/remotes/old/abranch.

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