Create a New Repository
Create a new empty repository on GitHub using gh
. This will be the destination for all your projects.
Add the Old Repositories as Remotes
Add each of the old repositories as a remote to the new repository. You will need the URL of each repository to do this. Replace old-repo-1
with a descriptive name for each remote repository.
Merge the Old Repositories into the New One
For each old repository, create a new branch, fetch the content, and merge it into the new repository. Replace old-repo-1
with the descriptive name you used in the previous step, and new-folder-1
with the desired folder name for the projects in the new repository.
git switch -c old-repo-1-branch
git pull old-repo-1 main
git mv * ../new-folder-1
git commit -m "Merging old-repo-1 into combined-repo"
git checkout main
git merge old-repo-1-branch --allow-unrelated-histories
git commit -m "Merged old-repo-1 into combined-repo"
Repeat this step for each old repository you want to merge into the new one, replacing the names accordingly.
Clean Up and Push Changes
After merging all the old repositories, you can remove the temporary branches and push the changes to the new repository.
Update References and Delete Old Repositories
If you have any references to the old repositories in other projects or scripts, update them to point to the new repository. Once you are sure you have successfully merged all the content and updated any references, you can delete the old repositories on GitHub using gh
.