{"thread":{"id":"65980","subject":"\"discard!\" commit message for commits that should be removed while cleaning up the history","startedAt":"2026-07-12T06:00:57Z","lastAt":"2026-07-12T13:28:41Z","messageCount":2,"participants":["Simon Richter","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"547877","messageId":"07c9811e-41db-473e-ba0a-cdcbf8187be7@hogyros.de","threadId":"65980","inReplyTo":null,"subject":"\"discard!\" commit message for commits that should be removed while cleaning up the history","fromName":"Simon Richter","fromEmail":"simon.richter@hogyros.de","sentAt":"2026-07-12T05:54:48Z","receivedAt":"2026-07-12T06:00:57Z","isPatch":false,"body":"Hi,\n\nI often add printf statements during debugging, which obviously should \nnot end up in the final submission. My usual approach is to commit these \nimmediately, into commits with a message of \"DISCARD\", so that when I do \na final rebase pass, I can remove the debug code easily.\n\nWould it make sense to add a mechanism that autosquash understands \ndirectly, and that could be checked for by a push hook or CI rule?\n\n    Simon\n"},{"id":"547898","messageId":"xmqqbjcc72wo.fsf@gitster.g","threadId":"65980","inReplyTo":"07c9811e-41db-473e-ba0a-cdcbf8187be7@hogyros.de","subject":"Re: \"discard!\" commit message for commits that should be removed while cleaning up the history","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-07-12T13:28:39Z","receivedAt":"2026-07-12T13:28:41Z","isPatch":false,"body":"Simon Richter <Simon.Richter@hogyros.de> writes:\n\n> I often add printf statements during debugging, which obviously should \n> not end up in the final submission. My usual approach is to commit these \n> immediately, into commits with a message of \"DISCARD\", so that when I do \n> a final rebase pass, I can remove the debug code easily.\n>\n> Would it make sense to add a mechanism that autosquash understands \n> directly, and that could be checked for by a push hook or CI rule?\n\nThe sequencer machinery used by \"git rebase [-i]\" already knows how\nto react to commits with certain subjects.  For example, a commit\nwith the subject \"fixup! <title>\" causes that commit to be moved\nnext to the target commit, and its \"pick\" insn is turned into a\n\"fixup\" insn.  The \"git commit\" command itself helps you prepare\nsuch a specially formatted commit title with options like \"--fixup\".\n\nSo, it is not totally out of the question to add support for\nnoticing a subject that begins with \"drop!\" (rather than your proposed\n\"DISCARD\", purely so that it matches the existing \"fixup!\" convention\nthat instructs the sequencer to use the \"fixup\" insn).  This would\nautomatically turn the \"pick\" insn into a \"drop\" insn when \"git\nrebase -i\" works on a history segment that includes such a commit.\n\nOn the \"git commit\" side, we likely do not want to add any support\nsimilar to the \"--fixup\" option (for example, \"--fixup=drop\"), as\nyou can run \"git commit -m 'drop!'\" just as easily.\n\nHaving said all that, you can use a custom GIT_SEQUENCE_EDITOR that\nnotices commits you titled \"DISCARD\" and rewrites the \"pick\" insn for\nthese commits into a \"drop\" insn in the todo list, without making\nany changes to Git.\n"}]}