Skip to content

Instantly share code, notes, and snippets.

@lablnet
Created May 7, 2021 12:52
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 lablnet/c97d68f7668dfa96376dd1a6224c09a7 to your computer and use it in GitHub Desktop.
Save lablnet/c97d68f7668dfa96376dd1a6224c09a7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage ./git.sh "commit msg" branch
if [ -z "$1" ]; then
echo "Please provide commit message."
exit
fi
# we can pull before commit or push
# check if branch is provide, if not make push it to default.
if [ -z "$2" ]; then
git pull
else
git pull origin $2
fi
# add files, commit and push changes.
git add -A
git commit -m "$1"
# check if branch is provide, if not make push it to default.
if [ -z "$2" ]; then
git push
else
git push origin $2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment