5 ms·
Could you share what your workflow would be? I’m assuming you put the point on the line you want to fix, then use Magit to start a rebase at the last commit tha
by shepmaster 6y ago
Could you share what your workflow would be? I’m assuming you put the point on the line you want to fix, then use Magit to start a rebase at the last commit that changed that line, then apply your changes, then continue?
I’m a casual Magit user, so learning from other users would be very beneficial.
- jpeloquin 6y agoThat works. My habit is to make the fix, commit it as "!fixup whatever", start an interactive rebase, move the fixup commit just after the bad commit (M-↑), press f on the fixup commit to tell rebase to merge it with the bad commit, and run the rebase (C-c C-c). This is pretty much the same method as yours, but committing first means the fixup will still be there if you have to cancel & redo the rebase for some reason, such as unexpected and confusing merge conflicts.
- shepmaster 6y agoRight, that process is what I do now, outside of Magit. The point of this article is a tool that (attempts to) automatically find the correct commit to combine with. Conceptually it removes the effort taken to move the fixup commit to the right spot; both keystroke-wise and mental effort wise. That’s what I’m looking for: a Magit-native way to make my little fixups without having to manually track which fixup should be applied where in history.
- globular-toast 6y ago> move the fixup commit just after the bad commit (M-↑), press f on the fixup commit to tell rebase to merge it with the bad commit, That's what --autosquash is for. If you do fixup commits correctly (using --fixup), it will put them in the correct place and mark them as fixups for you.
- shepmaster 6y ago> using --fixup If I understand you correctly, this requires that I think about which commit I want to fixup. Once identified, I can mark my fixup with what commit it should be combined with automatically. My understanding of the article is that it attempts to automatically figure out which commit to combine with. That’s the feature that I’m interested in.
- globular-toast 6y agoYeah, it does require you to think about it. But magit has really quick and easy diffing and blame so it can make it significantly easier. In practice I rarely have to think very hard before knowing which commit to fixup.
- jpeloquin 6y agoSo I guess what I should be doing is make fix → magit-blame to get the commit ID for the last prior edit → copy commit ID or message to clipboard → magit commit with `c F`, C-s to the commit ID I just copied, and C-c C-c to set up and run the autosquash rebase.
- shepmaster 6y agoThis process is what I think the article describes and what I’m curious if can be automated by magit itself.
- jpeloquin 6y agoMagit appears to have an integration with 'git absorb'. The issue that tracked the integration discussed git absorb as providing similar function to git autofixup. I don't particularly desire unsupervised changes to my commit history though so don't plan on looking into it further. https://github.com/magit/magit/issues/3053 https://github.com/magit/magit/issues/3053
- globular-toast 6y agoI typed it out but HN seems to be rate limiting me or something and tells me I'm "posting too fast". I seem to be able to post shorter comments, though. I've been meaning to write an article on a fixup workflow for a while now. Just need to find somewhere to host it.
- shepmaster 6y agoYou could throw it in a gist to start with.
- quodlibetor 6y agoIf you start doing a commit (via `c` in the magit status buffer, with the standard semantics of "you're going to commit everything that's currently staged") you can press capital F for an instant fixup, or capital S for instant squash. When you press either of those, magit pops up a commit picker which shows the current git log. Selecting a commit will then instantaneously apply your staged changes to the selected commit. It's much simpler than any of the other workflows I've seen in response to your question. The gif in this repo (for a tool I made that simulates this behavior as a cli tool for some jealous coworkers) tries to show the workflow: https://github.com/quodlibetor/git-fixup https://github.com/quodlibetor/git-fixup That said, this _doesn't_ support the "automatically figure out which commits to apply hunks to" workflow. I personally find that I use both workflows depending on the nature of my changes.