|
Archive:
Subtopics:
Comments disabled |
Sun, 31 May 2020
Reordering git commits (not patches) with interactive rebase
This is the third article in a series. ([1] [2]) You may want to reread the earlier ones, which were in 2015. I'll try to summarize. The original issue considered the implementation of some program feature X. In commit A, the feature had not yet been implemented. In the next commit C it had been implemented, and was enabled. Then there was a third commit, B, that left feature X implemented but disabled it:
but what I wanted was to have the commits in this order:
so that when X first appeared in the history, it was disabled, and then a following commit enabled it. The first article in the series began:
Using interactive rebase here “to reorder B and C” will not work
because My original articles described a way around this, using the plumbing
command Recently, Curtis Dunham wrote to me with a much better idea that uses the
interactive rebase UI to accomplish the same thing much more cleanly.
If we had B checked out and we tried
As I said before, just switching the order of these two M. Dunham's suggestion is to use
But what's
That is, “take a snapshot of that commit”. It's simple to implement:
There needs to be a bit of cleanup to get the working tree back into
sync with the new index.
M. Dunham's actual implementation
does this with I hadn't know about the Thank you again, M. Dunham! [Other articles in category /prog] permanent link You might be interested in the Recurse Center, a retreat for curious programmers. Here's what Julia Evans has written about it. |