Skip to content

Instantly share code, notes, and snippets.

@beefy
Last active May 10, 2017 17:34
Show Gist options
  • Save beefy/513c39f89fab527a51d9b0d7cbcc2db4 to your computer and use it in GitHub Desktop.
Save beefy/513c39f89fab527a51d9b0d7cbcc2db4 to your computer and use it in GitHub Desktop.
An alias to simplify git committing
#!/usr/bin/env bash
do_push() {
while true; do
read -p "ready to push? " yn
case $yn in
[Yy]* ) read -p "commit msg: " msg; git add . -A; git commit -m "$msg"; git push; break;;
* ) kill -INT $$;;
esac
done
}
check_diff() {
git diff;
git status -s;
git branch | grep "*";
do_push;
}
alias push=check_diff
alias b='git branch | grep "*"'
alias branch='git branch'
alias diff='git diff'
@beefy
Copy link
Author

beefy commented Apr 23, 2017

I find myself running a lot of commands when I make a commit, so I made an alias to reduce typing and forgetfulness.
It checks the diff, then a list of the files changed, then the current branch, and if I decide to commit [y/n], it does git add, git commit, and git push.

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