-
-
Save michaelpomogajko/27c063239f2e6d21676fc058c91c27fb to your computer and use it in GitHub Desktop.
[acp] add, commit, push #git #commit #shell #bash
This file contains hidden or 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 | |
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