←back to thread

1062 points mixto | 3 comments | | HN request time: 0.001s | source
Show context
beej71 ◴[] No.42942594[source]
Hey all--if you find things wrong, post 'em. I'll clean 'em up. :)

Love, Beej

replies(30): >>42942620 #>>42942694 #>>42942736 #>>42943486 #>>42943604 #>>42944525 #>>42945585 #>>42945722 #>>42946123 #>>42946210 #>>42946648 #>>42946913 #>>42947174 #>>42947352 #>>42947971 #>>42948270 #>>42948388 #>>42948408 #>>42949187 #>>42949195 #>>42949987 #>>42950982 #>>42952060 #>>42953388 #>>42953692 #>>42955126 #>>42959191 #>>42961534 #>>42974297 #>>42978137 #
aidos ◴[] No.42946123[source]
Not wrong, but since you’re mentioning vim in the context of git, might be worth adding :cq as a way to exit with a non-zero status to prevent git from finishing the commit / operation.
replies(7): >>42947682 #>>42948679 #>>42948693 #>>42950588 #>>42952635 #>>42954667 #>>43021805 #
1. ericholscher ◴[] No.42948693[source]
I usually use :q! which seems to do the same thing
replies(2): >>42952186 #>>42966198 #
2. alexjm ◴[] No.42952186[source]
The minor difference is that :q! quits without saving but returns zero as the exit code, but :cq quits with a nonzero exit code. Git interprets the nonzero exit code as "editing failed", following the Unix convention that zero means success. If you didn't save the commit message while working on it, :q! will send the empty template back to Git, which Git is smart enough to not commit. But if you accidentally save your work partway through, :q! will still commit the message you wanted to abandon.
3. sangnoir ◴[] No.42966198[source]
That only works if the edit buffer is blank or only has commented out lines. In other cases, such as when you're trying to cancel a `git commit --amend` that loads up the last commit message in your buffer, :q! will not cancel the commit, but :cq will.