Skip to content

Instantly share code, notes, and snippets.

@msawangwan
Created March 7, 2017 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msawangwan/85ee7ffbedde3d1eb5a599d06a0ded9b to your computer and use it in GitHub Desktop.
Save msawangwan/85ee7ffbedde3d1eb5a599d06a0ded9b to your computer and use it in GitHub Desktop.
[bash] git auto add-commit-push
#!/bin/bash -x
REQ_ARGS=2
BAD_ARGS_EXIT=65
if [ $# -ne $REQ_ARGS ]; then
echo
echo "usage: `basename $0` REPOSITORY BRANCH"
echo
exit $BAD_ARGS_EXIT
fi
echo
echo "**AUTO COMMIT PROCESS**"
echo
REPO=$1
BRANCH=$2
MESSAGE=$3
if [[ $3 == "" ]]; then
MESSAGE="all: auto commit"
fi
echo
echo "**REPO: $REPO BRANCH: $BRANCH**"
echo "**MESSAGE: $MESSAGE**"
echo
git status
git add .
git status
git commit -m "$MESSAGE"
git status
git push $REPO $BRANCH
git status
git remote show $REPO
echo
echo "**AUTO COMMIT COMPLETE**"
echo "**PUSHED TO REPO [$REPO] BRANCH [$BRANCH]**"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment