Copy Git repository with branches to another server
I'm migrating a legacy projects from one git server to another. I would like to keep all branches with me and not only the main.
In general, the steps can be summirized as follows:
- Clone remote repo locally
- checkout all remote branches
- Change origin url to new server
- Push everything to new origin
Clone repository to local git repo
git clone
Run script to checkout allthe branches
#!/bin/bash
for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote; done
Fetch all
git fetch --all
git pull --all
git fetch --tags
Check if required branches pulled locally
git branch
Replace origin url
git remote rm origin
git remote add origin https://new.server/project/app.git
Push all branches to new origin
git push origin --all
git push --tags
🚀 Turbocharge Your Infrastructure with Our Terraform Template Kits! 🚀
🌟 Slash deployment time and costs! Discover the ultimate solution for efficient, cost-effective cloud infrastructure. Perfect for DevOps enthusiasts looking for a reliable, scalable setup. Click here to revolutionize your workflow!
Learn More about Starter Terraform Kits for AKS,EKS and GKE
No comments are allowed for this post