I have several local git repositories which are logically separate projects. When each project is finished I want to make the entire repository a branch of an "archive" repository, just in case bugs appear in the future. Since, ultimately, each repository will be part of the archive repository I thought that I'd push each repository to a remote copy of the archive repository from the very beginning.
So I have separate repositories: archive, A, B, ... and I want to push them to a remote which will look like:
archive -- A as a branch
\---B as a branch
and so on.
I've searched through the git documentation, and on the net, and came up with the following alias for doing this:
backup = "!for br in $(git branch --column|sed 's/*//';); do git push archive ${br}:$(basename $PWD)/${br}; done"
So now, from A say, I can just do:
git remote add archive ssh://[email protected]/.../archive.git
git backup
This pushes each branch X in A are to a branch A/X on the remote. Unfortunately, each branch in A is a separate disconnected branch on the remote repository, so I have lost the history in A which isn't really what I want.
Is there a way of pushing all of the branches on A to a single branch (or rather a tree) on the remote repo? Or is my entire approach misguided and there is a better way to do this?
Cheers, Andrew
I found a question about merging repositories on stackoverflow and the answer by Olivier Verdier solves my problem: I just need to add the finished repo into the archive repository:
$ git remote add A /path/to/A
$ git fetch A
$ git remote add B /path/to/B
$ git fetch B
Done.