{"thread":{"id":"31271","subject":"Git feature request: --amend older commit","startedAt":"2012-08-17T15:47:49Z","lastAt":"2012-08-18T21:57:19Z","messageCount":6,"participants":["George Spelvin","Thomas Rast","Michael Haggerty","Jared Hance","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"197185","messageId":"20120817154749.11762.qmail@science.horizon.com","threadId":"31271","inReplyTo":null,"subject":"Git feature request: --amend older commit","fromName":"George Spelvin","fromEmail":"linux@horizon.com","sentAt":"2012-08-17T15:47:49Z","receivedAt":"2012-08-17T15:47:49Z","isPatch":false,"sender":{"key":"linux@horizon.com","avatar":null},"body":"With git's \"commit frequently\" style, I often find that I end up with a\ncommit that includes a typo in a comment or I forgot one call site when\nupdating functions or something.\n\nAnd it's a few commits later before I notice the simple oops.\n\nThis is of course fixable by making a commit, rebase -i HEAD~4 (or whatever),\nand marking the fixup for squashing into the previous commit.\n\nBut it would be really handy if there were a one-step command for doing this.\n\nSomething like \"git commit --fixup HEAD~3\", where \"git commit --fixup HEAD\"\nwould be equivalent to \"git commit --amend\".\n\nIt would be fine if it were implemented using rebase -i and you had to\nuse \"git rebase --continue\" to recover from a conflict.  And history had\nto be linear from the fixup point to HEAD.\n\nThe only thing I'd wish for, that rebase -i doesn't support, is a commit\nwith a dirty tree.  (Because often the typo is noticed in the middle of further\ndevelopment.)  But if I have to manually stash & pop, that would be good enough.\n\n\nTalking with some friends, they all say \"yeah, I would really use that\nfeature\".  So I figured I'd mention it here.\n"},{"id":"197189","messageId":"502E725B.2040906@alum.mit.edu","threadId":"31271","inReplyTo":"20120817154749.11762.qmail@science.horizon.com","subject":"Re: Git feature request: --amend older commit","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-08-17T16:33:31Z","receivedAt":"2012-08-17T16:33:31Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 08/17/2012 05:47 PM, George Spelvin wrote:\n> With git's \"commit frequently\" style, I often find that I end up with a\n> commit that includes a typo in a comment or I forgot one call site when\n> updating functions or something.\n>\n> And it's a few commits later before I notice the simple oops.\n>\n> This is of course fixable by making a commit, rebase -i HEAD~4 (or whatever),\n> and marking the fixup for squashing into the previous commit.\n>\n> But it would be really handy if there were a one-step command for doing this.\n>\n> Something like \"git commit --fixup HEAD~3\", where \"git commit --fixup HEAD\"\n> would be equivalent to \"git commit --amend\". [...]\n\nHave you tried \"git rebase --autosquash\"?  It does part of what you are \nasking for and additionally allows multiple fixup commits to be queued \nup and processed in a single rebase.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"197187","messageId":"87628heapy.fsf@thomas.inf.ethz.ch","threadId":"31271","inReplyTo":"20120817154749.11762.qmail@science.horizon.com","subject":"Re: Git feature request: --amend older commit","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2012-08-17T16:37:13Z","receivedAt":"2012-08-17T16:37:13Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"\"George Spelvin\" <linux@horizon.com> writes:\n\n> With git's \"commit frequently\" style, I often find that I end up with a\n> commit that includes a typo in a comment or I forgot one call site when\n> updating functions or something.\n[...]\n> But it would be really handy if there were a one-step command for doing this.\n>\n> Something like \"git commit --fixup HEAD~3\", where \"git commit --fixup HEAD\"\n> would be equivalent to \"git commit --amend\".\n\nUmm, --fixup is already taken and makes the subject be 'fixup! <subject\nof argument>'.  This can then be used by rebase -i --autosquash (or\nrebase.autosquash=true) to automatically put the fixup(s) that have\naccumulated into the right places.  In addition, git-rebase learned to\nautomatically use the upstream as the default base.\n\nSo for me it's usually a matter of\n\n  git add -p\n  git commit --fixup=...\n  # repeat the above two until all fixups are lined up\n  git rebase -i\n  # close editor without making changes\n\nIs that still too much effort?\n\n\n<plug mode=shameless>\n\nThe ideas discussed in\n  http://thread.gmane.org/gmane.comp.version-control.git/202535/focus=202569\nalso help selecting the fixup argument more quickly.\n\n</plug>\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"197191","messageId":"20120817170005.27451.qmail@science.horizon.com","threadId":"31271","inReplyTo":"502E725B.2040906@alum.mit.edu","subject":"Re: Git feature request: --amend older commit","fromName":"George Spelvin","fromEmail":"linux@horizon.com","sentAt":"2012-08-17T17:00:05Z","receivedAt":"2012-08-17T17:00:05Z","isPatch":false,"sender":{"key":"linux@horizon.com","avatar":null},"body":"> Have you tried \"git rebase --autosquash\"?  It does part of what you are \n> asking for and additionally allows multiple fixup commits to be queued \n> up and processed in a single rebase.\n\nNo, I hadn't!  It's not *quite* as simple as what I had hoped for, but\ndefinitely is progress in that direction.\n\nIn particular, I can probably manage to use those to write a script that\ndoes what I want.  Something that ends up with something like\n\"EDITOR=/bin/true git rebase -i --autosquash $base\"\n\nThanks you!  I apologize for my failure to (Re-) RTFM.  I have done so\nnumerous times, but the feature wasn't there last time I looked.\n"},{"id":"197234","messageId":"20120818014139.GA11100@gentoo.cinci.rr.com","threadId":"31271","inReplyTo":"20120817154749.11762.qmail@science.horizon.com","subject":"Re: Git feature request: --amend older commit","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2012-08-18T01:41:39Z","receivedAt":"2012-08-18T01:41:39Z","isPatch":false,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"On Fri, Aug 17, 2012 at 11:47:49AM -0400, George Spelvin wrote:\n> Something like \"git commit --fixup HEAD~3\", where \"git commit --fixup HEAD\"\n> would be equivalent to \"git commit --amend\".\n\nAside from the ways others mentioned on how to do this, I think that a\nbetter interface if this were to be added would be to make the commit an\noptional parameter of --amend. Adding another parameter which\neffectively does a superset of --amend sounds unnecessary.\n\nI often want to amend a commit, but its simply too much work, so I\nusually commit it marking the message as something like\n\"fixup! ...\". Then, before I push, I make sure to rebase all of\nthe commits marked as fixups. Clearly autosquash does this, but to have\nto override the editor as \"true\" is just a hassle.\n\nI feel like this is a common enough need that it deserves more first\nclass support than relying on the rebase command and then using true as\nan editor. Either it should be supported natively or it should be\npossible to autosquash a rebase without --interactive, since at present\n--autosquash requires --interactive, which isn't nice for when the user\ndoes not want the rebase to be interactive. Such a simple task shouldn't\nrequire an interactive command.\n"},{"id":"197268","messageId":"7vr4r3rhhc.fsf@alter.siamese.dyndns.org","threadId":"31271","inReplyTo":"20120818014139.GA11100@gentoo.cinci.rr.com","subject":"Re: Git feature request: --amend older commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-18T21:57:19Z","receivedAt":"2012-08-18T21:57:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jared Hance <jaredhance@gmail.com> writes:\n\n[administrivia: do not deflect a direct response to you away by\nusing mail-followup-to header, thanks]\n\n> On Fri, Aug 17, 2012 at 11:47:49AM -0400, George Spelvin wrote:\n>> Something like \"git commit --fixup HEAD~3\", where \"git commit --fixup HEAD\"\n>> would be equivalent to \"git commit --amend\".\n\nYes, as an end-user facing command set, \"git commit --amend HEAD~3\" would\nnot be a bad addition.\n\n> Such a simple task shouldn't require an interactive command.\n\nIn some cases, yes.  But the devil is in the details, and whoever\nwants to work on must be prepared to see cases where the remainder\nof the commits after rewriting an older commit will not replay\ncleanly on top of it.  At that point, it won't be a simple task\nanymore.  At least, it must make it clear what the user should do\nwhen \"commit --amend HEAD~3\" (and subsequent rebuilding of HEAD~2,\nHEAD~1 and HEAD on top of the amended result) needs a help from the\nuser to resolve conflicts.  It may be just the matter of mentioning\n\"from here on, follow the procedure you would use when you are\nrunning 'rebase -i'\", if the chosen mechanism to implement the\nsequencing behind the \"commit --amend HEAD~3\" UI is \"rebase -i\".\n"}]}