Skip to content

Instantly share code, notes, and snippets.

@groupsky
Created November 23, 2011 17:06
Show Gist options
  • Save groupsky/1389227 to your computer and use it in GitHub Desktop.
Save groupsky/1389227 to your computer and use it in GitHub Desktop.
Backup git repo to another repo
#!/bin/bash
# Pushesh all branch heads from origin remote to backup repo
# prerequisites:
# 1. git clone <from the origin>
# 2. git remote add backup <backup repo>
git branch -a | grep remotes/origin | cut '-d/' -f3 | grep -v HEAD | while read i; do git push -u backup remotes/origin/$i:refs/heads/$i; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment