Skip to content

Instantly share code, notes, and snippets.

@NthPortal
Created January 4, 2022 19:50
Show Gist options
  • Save NthPortal/fc70004289989fb7561e9a6e999ca977 to your computer and use it in GitHub Desktop.
Save NthPortal/fc70004289989fb7561e9a6e999ca977 to your computer and use it in GitHub Desktop.
git scripts
#!/bin/bash
[ $# != 1 ] && echo "expects exactly one arg" && exit 1
if branch_name=$(git symbolic-ref --short -q HEAD) ; then
new_end="$1"
branch_name="${branch_name%/*}/$new_end"
git checkout -b "$branch_name"
else
echo "not on any branch" && exit 1
fi
#!/bin/bash
[ $# != 0 ] && echo "does not take args" && exit 1
if branch_name=$(git symbolic-ref --short -q HEAD) ; then
pr_branch="${branch_name%/*}/PR"
git checkout "$pr_branch" && git reset --hard "$branch_name"
else
echo "not on any branch" && exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment