Skip to content

Instantly share code, notes, and snippets.

@michaelpomogajko
Last active August 2, 2018 14:54
Show Gist options
  • Save michaelpomogajko/27c063239f2e6d21676fc058c91c27fb to your computer and use it in GitHub Desktop.
Save michaelpomogajko/27c063239f2e6d21676fc058c91c27fb to your computer and use it in GitHub Desktop.
[acp] add, commit, push #git #commit #shell #bash
#!/bin/bash
if [ ! -d '.git' ]
then
echo 'Git not initialized in this folder'
exit 1
fi
if [ -z "$1" ]
then
echo 'Requires at least 1 arguments'
exit 1
fi
current_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
msg=$1
remote_branch=''
if [ -n "$2" ]
then
remote_branch=$2
else
remote_branch=$current_branch
fi
git add -A && \\
git commit -m "$msg" && \\
git push origin $current_branch:$remote_branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment