Re: why does "git revert" commit even if i try to bail with ":q!"?
- From
Elijah Newren <newren@gmail.com>
- Date
- Mar 12, 2019, 18:24 UTC
- Message-ID
- <CABPp-BHV9+7+3si8NOA0ouYZ_Zyo5yMqMbSggwoYmRLK-kB_dA@mail.gmail.com>
- In-Reply-To
- <alpine.LFD.2.21.1903121419070.18042@localhost.localdomain>
On Tue, Mar 12, 2019 at 11:21 AM Robert P. J. Day <rpjday@crashcourse.ca> wrote:
Show 18 quoted lines
> > On Tue, 12 Mar 2019, Kevin Daudt wrote: > > ... snip ... > > > The only reason why `:q!` works just for comitting is because there > > is no default message, so the final message ends up empty. > > > > When you do things like git revert or git commit --amend, there is > > already a commit message, which you are then editing. When you quit > > without saving, the existing message remains and git uses that. > > > > vim has a command to let it exit with an error return code: `:cq`. > > This makes git something went wrong with editing the message, > > causing git to abort the commit. > > ah, i'm starting to get it. predictably, i think this needs to be > mentioned in a man page. :-) thanks muchly for clearing that up.
If you do fix up some manpage, note that this affects e.g. commit --amend too as pointed out by Kevin (and maybe also the 'reword' option of git-rebase?) -- anything that starts with .git/COMMIT_MSG being non-empty.