This beautiful Linux terminal app will help you ditch the git command line for good. Its responsive layout and keyboard interface help to tackle the challenge of even complex git commands.
Lazygit is a TUI for Git
Lazygit is a tool designed to ease your day-to-day git use. The git command-line program is definitely worth learning, but it’s highly complex. It may offer a huge number of features, but you probably only use a tiny subset of them. Even so, it can be hard to remember those commands that are essential yet rare, like bisect or stash.
Like many modern apps for the command line, Lazygit has a multi-line text interface to approximate a GUI. It’s a compromise between the sparse minimalism of git and the mouse-driven, fully graphical interfaces of tools like GitKraken and SourceTree. In fact, the overall layout will be familiar if you’re a user of the GitHub Desktop app.
Lazygit lets you do all the basics using the keyboard, from stashing and committing to switching branches or checking out new worktrees. Basic mouse support is available, too, but the nature of the TUI means that keyboard navigation is quick and easy.
How to install and use Lazygit
You can install Lazygit using your distribution’s package manager: sudo apt install lazygit on current Debian/Ubuntu, or brew install lazygit on macOS. Package managers are supported for many other systems; check the project’s README for further details.
Once installed, simply run lazygit from a checked-out repository. You should see an interface similar to this:
Lazygit uses an adaptive layout, so you can resize your terminal window, and individual panels will adjust accordingly.
Each of the main panels is labeled with a number from 0 to 5. Press one of these keys to activate the corresponding panel. Some panels present different tabs, and you can switch between these tabs in the active panel using [ (left bracket) and ] (right bracket).
Lazygit supports different layouts, so you can focus on a particular panel or show more panels at once. Pressing + cycles through these layouts, ensuring that the active panel remains visible. For example, expanding the third panel when showing tags provides a two-column view, with the tag panel on the left and details about that specific tag on the right:
Pressing + again will show a single, full-sized panel listing all tags:
In this view, you can still press 0 to switch to the detail panel, or the shortcut for any other panel to switch to it instead. This flexibility means that you can quickly adapt Lazygit to whichever layout you prefer for your task. This is a bit like using a tiling window manager and, if you’ve ever used one before, you’ll appreciate how much faster it can be to adjust layout using the keyboard.
These Lazygit features really stand out
Like many TUIs, Lazygit has excellent support for mouse control. Simply click somewhere on screen, and the app will usually behave as you would expect, switching panels and tabs, selecting individual items from lists, and paging through long lists. A mouse click will also open the two ever-present links in the app’s footer to donate or ask a support question. You can even use a scroll wheel to move through long lists, too.
Lazygit’s commit graph presents a nice view of branches and merges, using simple line drawing to represent them, in a similar way to GUIs like Fork or GitKraken. The view also color-codes by author, making it easy to track down who did what:
Lazygit provides basic textboxes for you to enter things like commit messages. But it also lets you switch to your editor to write such messages in a more familiar, featureful environment:
You can even use this feature to edit files directly from Lazygit, turning it into an IDE of sorts.
The feature that I think I’ve found most useful, so far, is selective staging. This is great when, like me, you tend to make lots of distinct changes at once. When it comes to committing, it helps to select relevant changes from a file and ignore others, for the time being. You can do this really easily with Lazygit by following these steps:
- In the Files panel, select the file you wish to stage and press Enter, which will focus the “Unstaged changes” panel on the right.
- Move the cursor up/down to select individual lines and stage them with space.
- Press a to select whole hunks at once, then Space to stage them.
- Once you’re happy, press Escape to return to the Files panel and c to commit your changes.
It takes a bit of time and effort to learn Lazygit’s keyboard shortcuts, although help is always readily available. Beginners should find it much easier to get to grips with than some of git’s obscure command-line options, and experts will be grateful for the time saved during commonly-repeated tasks.
