Skip to content

Instantly share code, notes, and snippets.

@MrAmbiG
Last active July 26, 2020 16:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrAmbiG/42d4f2e8af91bf061d3b616639fed4d3 to your computer and use it in GitHub Desktop.
Save MrAmbiG/42d4f2e8af91bf061d3b616639fed4d3 to your computer and use it in GitHub Desktop.
mirror repos
# 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