github repo全分支备份实践

521 阅读1分钟
  1. 新建backup repo
  2. 下载源repo
git clone git@github.com:yourname/yourrepo.git backup
  1. 拉取所有分支
    参考how-do-i-fetch-all-git-branches
cd backup
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
  1. 添加backup库地址
git remote add backup git@github.com:yourname/yourrepobackup.git
  1. 推送所有barch到backup repo
    参考Push local Git repo to new remote including all branches and tags
git push backup '*:*