Last active
July 26, 2020 16:50
-
-
Save MrAmbiG/42d4f2e8af91bf061d3b616639fed4d3 to your computer and use it in GitHub Desktop.
mirror repos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clone the repo from your existing git source [gilab, github etc] | |
git clone OLDREPO | |
# cd into the cloned repo | |
cd NEWCLONEDREPO | |
# check in and check out of all clones branches to mirror them locally | |
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done | |
# fetch and pull | |
git fetch --all | |
git pull --all | |
# Add new origin [point to new git site] | |
git remote add new_origin NEWREPO | |
git push --all new_origin | |
git push --tags new_origin | |
# list current remotes | |
git remote -v | |
# remove old remote | |
git remote rm origin | |
# rename new remote as origin | |
git remote rename new_origin origin | |
git remote -v | |
git branch -a | |
echo '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment