Skip to content

Instantly share code, notes, and snippets.

@phloreenm
Forked from msadouni/git-branch-backup.sh
Created November 16, 2022 12:09
Show Gist options
  • Save phloreenm/dd57d3afd02c0ecdcb7cba1975523df3 to your computer and use it in GitHub Desktop.
Save phloreenm/dd57d3afd02c0ecdcb7cba1975523df3 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