Skip to content

Instantly share code, notes, and snippets.

@mpharrigan
Created October 14, 2021 16:16
Show Gist options
  • Save mpharrigan/95c7c9be795b3f3704f57f0d721dd0ff to your computer and use it in GitHub Desktop.
Save mpharrigan/95c7c9be795b3f3704f57f0d721dd0ff to your computer and use it in GitHub Desktop.
set -e
# config: set this to your remote name
remote='origin'
branch_c='-c'
push_f=''
while getopts f flag
do
case "${flag}" in
f) branch_c='-C' push_f='-f';;
esac
done
oldname=`git rev-parse --abbrev-ref HEAD`
newname=$oldname-`date +%F-%Hh`
git branch $branch_c $newname
git branch --unset-upstream $newname
git push $push_f $remote $newname:$newname -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment