How to Move a Complete Git Repository
Moving a Git repository while preserving all branches, tags, and history requires careful handling. This guide covers the step-by-step process to migrate your repository safely.
Quick Method
For those familiar with Git, here's the quick version:
git clone --mirror $ORIG_REPO_URL temp-dir
cd temp-dir
git remote rm origin
git remote add origin $NEW_REPO_URL
git push origin --all
git push --tags
Detailed Steps
Clone the Original Repository
git clone --mirror $ORIG_REPO_URL temp-dirThe
--mirrorflag creates a bare repository, including all branches and tags.Navigate to Directory
cd temp-dirUpdate Remote Configuration
git remote rm origin git remote add origin $NEW_REPO_URLThis step redirects the repository to its new destination.
Push All Content
git push origin --all git push --tagsThese commands transfer all branches and tags to the new location.
Verification
After migration, verify:
All branches are present in the new repository
Commit history is intact
Tags are properly transferred
Remote URLs are correctly configured
