Skip to content

Instantly share code, notes, and snippets.

@bogvsdev
Last active March 11, 2017 22:44
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 bogvsdev/26dadf6c51215827dd76b125380c2cf5 to your computer and use it in GitHub Desktop.
Save bogvsdev/26dadf6c51215827dd76b125380c2cf5 to your computer and use it in GitHub Desktop.
Shortcut command for adding changes to git and publishing it to repository
gitp() {
# get current git branch as string
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)" # detached HEAD
branch_name=${branch_name##refs/heads/}
# check for commit message
if [ ${#1} == 0 ]; then
commit='commit'
else
commit=`echo "$1"`
fi
# publish
git add -A;
git commit -m "${commit}";
git push origin "${branch_name}"
}

Git shortcut usage

Just add this function to your .bash_profile or .bashrc file and you'll be able to run it!

gitp will publish changes to current branch with default commit gitp "added new feature" will publish changes to current branch with specified commit

Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment