Re: How to prevent empty git commit --amend
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jan 14, 2015, 12:45 UTC
- Message-ID
- <vpqvbk9a5uc.fsf@anie.imag.fr>
- In-Reply-To
- <CA+iO_8nmrw7SiXWS22VcEHObQDJYDwKqRPariAmv5DzUvzAdsQ@mail.gmail.com>
Ivo Anjo <ivo.anjo@ist.utl.pt> writes:
Show 10 quoted lines
> Hello, > > On Wed, Jan 14, 2015 at 10:00 AM, Matthieu Moy > <Matthieu.Moy@grenoble-inp.fr> wrote: >> [alias] >> amend = !git diff --staged --quiet || git commit --amend >> >> and then use "git amend". > > Genius! This is exactly what I wanted, thanks!
You probably want to tweak the alias by adding a && echo "Nothing to commit, sorry" (or an if/then/fi) after git diff to get the appropriate error message though.
-- Matthieu Moy http://www-verimag.imag.fr/~moy/