Skip to content

Instantly share code, notes, and snippets.

@msadouni
Created April 6, 2012 15:11
Show Gist options
  • Save msadouni/2320675 to your computer and use it in GitHub Desktop.
Save msadouni/2320675 to your computer and use it in GitHub Desktop.
Backup a Git branch
#!/bin/sh
# Usage: git-branch-backup.sh <remote>
# Originally from jlecour but I can't find his version anymore
if [ -z "$1" ]
then
remote='origin'
else
remote=$1
fi
set -e
CUR=`git branch | grep '\*' | awk '{print $2}'`
git push --force ${remote} ${CUR}:backup/${USER}/${CUR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment