Git clone all branches and push to a different remote
Step 0x01 - add your own remote
# add another remote
git remote add mrzenw_github __ANOTHER_REMOTE_GIT_ADDRESS__HTTPS_OR_SSH__
Step 0x02 - create local branches as same as them in the origin repository
# checkout all branches
# https://stackoverflow.com/a/10312587
# fetch and pull
git fetch --all
git pull --all
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track " ${remote# origin/ } " " $remote " ; done
git fetch --all
git pull --all
Step 0x03 - push to your own remote
# push all branches from `origin` to `mrzenw_github` remote
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git push -u mrzenw_github " ${remote# origin/ } " ; done
# add another remote
git remote add mrzenw_github __ANOTHER_REMOTE_GIT_ADDRESS__HTTPS_OR_SSH__
# checkout all branches
# https://stackoverflow.com/a/10312587
# fetch and pull
git fetch --all
git pull --all
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track " ${remote# origin/ } " " $remote " ; done
git fetch --all
git pull --all
# push all branches from `origin` to `mrzenw_github` remote
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git push -u mrzenw_github " ${remote# origin/ } " ; done
Step 0x11 - set the origin upstream back to the original remote
# fetch and pull
git fetch --all
git pull --all
# set back upstream remote to `origin`
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch -u origin " ${remote# origin/ } " ; done
Step 0x12 - create local branches as same as them in the origin repository
# checkout all branches
# https://stackoverflow.com/a/10312587
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track " ${remote# origin/ } " " $remote " ; done
git fetch --all
git pull --all
Step 0x13 - push to your own remote
# push all branches from `origin` to `mrzenw_github` remote
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git push -u mrzenw_github " ${remote# origin/ } " ; done
# fetch and pull
git fetch --all
git pull --all
# set back upstream remote to `origin`
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch -u origin " ${remote# origin/ } " ; done
# checkout all branches
# https://stackoverflow.com/a/10312587
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track " ${remote# origin/ } " " $remote " ; done
git fetch --all
git pull --all
# push all branches from `origin` to `mrzenw_github` remote
git branch -r | grep -v ' \->' | grep ' origin/' | sed " s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git push -u mrzenw_github " ${remote# origin/ } " ; done