Mirror Git Repo

Mirror Git Repo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
git clone <repo-url>
cd <repo-name>
git branch -r \
  | grep -v '\->' \
  | 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
git remote add <mirror-name> <mirror-url>
git push --mirror <mirror-name>

Reference

How to fetch all branches locally