Last active
April 13, 2016 15:25
-
-
Save mavalur/92b4b024b73dd6e8c32ad9b9acaecee0 to your computer and use it in GitHub Desktop.
push script to git
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 | |
CODEBASE=<CODE_BASE> | |
date=`DATE` | |
commitMessage="Logical commit for $date" | |
branchname="release/2.1" | |
pullandcommit=false | |
function usage | |
{ | |
echo "sh $0 -m 'message'" | |
} | |
function commitnow | |
{ | |
cd $CODEBASE | |
if [[ $pullandcommit == true ]]; then | |
git pull origin $branchname | |
echo "git pull from $branchname completed" | |
fi | |
git add . | |
echo "files added to index" | |
git commit -m "$commitMessage" | |
git push origin $branchname | |
cd - | |
exit | |
} | |
while [ "$1" != "" ]; do | |
case $1 in | |
-m | --message ) shift | |
commitMessage=$1 | |
;; | |
-p | --pull ) | |
pullandcommit=true | |
;; | |
-b | --branch ) shift | |
branchname=$1 | |
;; | |
-h | --help ) usage | |
exit | |
;; | |
* ) usage $0 | |
exit 1 | |
esac | |
shift | |
done | |
commitnow | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment