Paul C. Anagnostopoulos via llvm-dev
2021-Jan-20 18:35 UTC
[llvm-dev] Git question about revert
This morning I pushed a commit that killed the build, so I reverted it and pushed the new commit to fix the build. Then I did another revert to get my changes back so I can work on them some more. Is it legitimate to use that second revert commit, which was never pushed, to do the additional work, changing the title to something reasonable? If not, could you explain what I ought to do?
Yes, that is a reasonable workflow. Once the changes are made to fix the problems with the original commit, I often see folks land the revert of the revert with a title like `Reland "<original title>"` rather than `Revert "Revert "<original title>""`. On Wed, Jan 20, 2021 at 10:39 AM Paul C. Anagnostopoulos via llvm-dev < llvm-dev at lists.llvm.org> wrote:> This morning I pushed a commit that killed the build, so I reverted it and > pushed the new commit to fix the build. Then I did another revert to get my > changes back so I can work on them some more. > > Is it legitimate to use that second revert commit, which was never pushed, > to do the additional work, changing the title to something reasonable? If > not, could you explain what I ought to do? > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210120/71bc27f5/attachment.html>
> -----Original Message----- > From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Paul C. > Anagnostopoulos via llvm-dev > Sent: Wednesday, January 20, 2021 1:36 PM > To: llvm-dev at lists.llvm.org > Subject: [llvm-dev] Git question about revert > > This morning I pushed a commit that killed the build, so I reverted it and > pushed the new commit to fix the build. Then I did another revert to get > my changes back so I can work on them some more. > > Is it legitimate to use that second revert commit, which was never pushed, > to do the additional work, changing the title to something reasonable? If > not, could you explain what I ought to do?Whatever workflow you do on your own is up to you, really. Depending on the circumstances, or just my mood, I might do git reset HEAD~1 which puts HEAD back to the first revert, but leaves the files in your working tree as they were after the second revert. When you're done, you can commit them like any other new work. It's like starting over just before you did that first commit. Another option is to leave the second revert commit there, and then any new changes can be added to it using git commit --amend This takes the usual "commit" options like -a (all modified files). Another useful one is "-C HEAD" which leaves the commit message unchanged; normally --amend will pop you into vim (or whatever editor you have set) to modify the original commit message. Editing is handy because reviewers like to see something in the new commit message that says how you fixed the problem that the first commit caused. One issue with revert-of-revert is that "git revert" prepends that "Revert foo" text onto the headline. Do that too many times and the entire commit message starts to look like Revert "Revert "Revert "Revert "Revert "Revert ... and I believe I have actually seen one with 6 Reverts, which made the llvm-commits email subject line pretty useless. While it might be amusing the first time you see it, I don't like it because the *real* commit message is obscured. What I suggest to people is that if they revert a revert, they should modify the commit message from Revert "Revert "my clever patch"" to Reapply "my clever patch" (some people prefer "Reland") or just go back to the original my clever patch which better describes what the commit is actually about. --paulr
On Wed, Jan 20, 2021 at 10:39 AM Paul C. Anagnostopoulos via llvm-dev < llvm-dev at lists.llvm.org> wrote:> This morning I pushed a commit that killed the build, so I reverted it and > pushed the new commit to fix the build. Then I did another revert to get my > changes back so I can work on them some more. > > Is it legitimate to use that second revert commit, which was never pushed, > to do the additional work, changing the title to something reasonable? If > not, could you explain what I ought to do? >That works, in general I tend to `git cherry-pick <original commit>` instead, because it brings back the original commit description with it :) (and possible link to the phabricator revision). I'll still edit the message (git commit --amend) to add that this is a reland after fixes. -- Mehdi> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210120/4d61788b/attachment-0001.html>