Tech News
← Back to articles

Rebasing in Magit

read original related products more articles

Here I have opened the git log1 I’m sorry about the mouse cursor – it’s an artifact of selecting the area to screenshot., by first opening Magit (which I have bound to the F3 key), and then pressing lL . The first l is the prefix key for dealing with the git log, and the second L is to to view the log for all local branches (and the remote branches they track.)

Hypothetically, if we wanted to run a more complicated log command, it is very easy to do that in Magit. When we press the first l and pause for a moment, Magit shows us unintrusive hints for all options that are available:

This means we don’t have to remember exactly which options there are because if we need them, Magit will remind us. Some examples:

To limit to a particular author, we type -A and then Magit gives us a fuzzy-matching list of all repository authors. We can either browse that list, or type the name of the author we are interested in and press return to confirm.

and then Magit gives us a fuzzy-matching list of all repository authors. We can either browse that list, or type the name of the author we are interested in and press return to confirm. To limit the date range of the log, we type =u and then Magit gives us a calendar view in which we can select a date, or type one manually.

and then Magit gives us a calendar view in which we can select a date, or type one manually. Then we want a graph view with colour and decorations and no merge commits. This is already enabled by default in this configuration. (Indicated by bold and highlighted flag names.)

We want to see file diffstats, so we type -s .

. Oh, and we only care about files in the tests subdirectory, so we type -- to limit to files and then type tests and confirm with return.

With this configuration, we want to look at all branches, including remote ones. We get that view by finally pressing b .

This is a high level of discoverability for git! I have always been that guy listed in git.txt, but Magit’s discoverability still teaches me a lot of new ways to use git. But it’s not only discoverable, it’s also quick. Here’s the full sequence of keypresses, with ␍ standing for confirming with return:

... continue reading