Created
January 4, 2022 19:50
-
-
Save NthPortal/fc70004289989fb7561e9a6e999ca977 to your computer and use it in GitHub Desktop.
git scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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