Skip to content

Instantly share code, notes, and snippets.

@rawnly
Last active January 14, 2021 14:18
Show Gist options
  • Save rawnly/71b6e53d4144e0515f19efa59837051e to your computer and use it in GitHub Desktop.
Save rawnly/71b6e53d4144e0515f19efa59837051e to your computer and use it in GitHub Desktop.
# Usage: commit <message> [-a|--add] [-p|--push]
# Example: commit "my first commit" -a -p
# GIT Equivalent:
# - git add -A .
# - git commit -a -m "NEXT-<*>: my first commit"
# - git push
function commit {
if [ -z $1 ]; then
echo "No commit message";
return 0;
fi;
branch=$(git branch | grep '*' | grep -Eo 'NEXT-[0-9]+');
if [ -z "$branch" ]; then
echo "WARN! Not a NEXT branch";
else
branch="${branch}:";
fi;
if [ "$2" = "--add" ] || [ "$2" = "-a" ]; then
git add -A .
fi;
git commit -a -m "${branch} $1";
if [ "$3" = "--push" ] || [ "$3" = "-p" ]; then
git push;
fi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment