Drop git changes with a confirm
Drop the following into your ~/.bash_profile and you will be able to use the drop
command and you will be prompted to drop all of your changes since the last commit.
# ~/.bash_profile
alias hard_drop="git reset HEAD --hard"
alias drop="confirm && hard_drop"
confirm () {
# call with a prompt string or use a default
read -r -p "${1:-Hard reset to last commit? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
# example use in terminal
$ drop
> Hard reset to last commit? [y/N]
$ y
> HEAD is now at <commit ref> Some Commit Message
Written by Mike Piccolo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#