I have several repositories (around 10) which I would like to archive. By "archive", I mean moving them to a new repo called "archive. If I git archive
them, they would be made read-only but still be listed in my repos.And I would like to avoid that to let my team see only the active repos and also to keep the list short. So, can you please suggest a way to move several repos to a new repo and preserve their history? Thank you!
CodePudding user response:
So, can you please suggest a way to move several repos to a new repo and preserve their history?
yes, these is. And I think this question is basically a git question.
You can first git clone all of your repository to local(Include the repository you want to move to).
For example, you git clone two repositories named testrepo1 and testrepo2:
And you want to merge testrepo1 to testrepo2 and keep the histories, just follow the below steps:
cd testrepo2
git remote add testrepo1 <Absolute path of testrepo1>
git fetch testrepo1 --tags
git merge --allow-unrelated-histories testrepo1/main
git push
Ten repositories is not very much, you can manually do the above steps, or you can write code to auto run the above steps(If you use script, please make sure you give the script enough time to do git operation, otherwise something will missing.).
PS:
Just notice, --allow-unrelated-histories is only available when git >= 2.9, otherwise you will be unable to use this.