Git development
 help / color / mirror / Atom feed
* "discard!" commit message for commits that should be removed while cleaning up the history
@ 2026-07-12  5:54 Simon Richter
  2026-07-12 13:28 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Richter @ 2026-07-12  5:54 UTC (permalink / raw)
  To: git


[-- Attachment #1.1: Type: text/plain, Size: 440 bytes --]

Hi,

I often add printf statements during debugging, which obviously should 
not end up in the final submission. My usual approach is to commit these 
immediately, into commits with a message of "DISCARD", so that when I do 
a final rebase pass, I can remove the debug code easily.

Would it make sense to add a mechanism that autosquash understands 
directly, and that could be checked for by a push hook or CI rule?

    Simon

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: "discard!" commit message for commits that should be removed while cleaning up the history
  2026-07-12  5:54 "discard!" commit message for commits that should be removed while cleaning up the history Simon Richter
@ 2026-07-12 13:28 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2026-07-12 13:28 UTC (permalink / raw)
  To: Simon Richter; +Cc: git

Simon Richter <Simon.Richter@hogyros.de> writes:

> I often add printf statements during debugging, which obviously should 
> not end up in the final submission. My usual approach is to commit these 
> immediately, into commits with a message of "DISCARD", so that when I do 
> a final rebase pass, I can remove the debug code easily.
>
> Would it make sense to add a mechanism that autosquash understands 
> directly, and that could be checked for by a push hook or CI rule?

The sequencer machinery used by "git rebase [-i]" already knows how
to react to commits with certain subjects.  For example, a commit
with the subject "fixup! <title>" causes that commit to be moved
next to the target commit, and its "pick" insn is turned into a
"fixup" insn.  The "git commit" command itself helps you prepare
such a specially formatted commit title with options like "--fixup".

So, it is not totally out of the question to add support for
noticing a subject that begins with "drop!" (rather than your proposed
"DISCARD", purely so that it matches the existing "fixup!" convention
that instructs the sequencer to use the "fixup" insn).  This would
automatically turn the "pick" insn into a "drop" insn when "git
rebase -i" works on a history segment that includes such a commit.

On the "git commit" side, we likely do not want to add any support
similar to the "--fixup" option (for example, "--fixup=drop"), as
you can run "git commit -m 'drop!'" just as easily.

Having said all that, you can use a custom GIT_SEQUENCE_EDITOR that
notices commits you titled "DISCARD" and rewrites the "pick" insn for
these commits into a "drop" insn in the todo list, without making
any changes to Git.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-12 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12  5:54 "discard!" commit message for commits that should be removed while cleaning up the history Simon Richter
2026-07-12 13:28 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox