Jens Müller
Jens Müller

Reputation: 402

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

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?

Upvotes: 2

Views: 522

Answers (1)

VonC
VonC

Reputation: 1325377

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.

Upvotes: 2

Related Questions