(Last Updated On: August 13, 2018)

In this tutorial, we’ll look at how to install and use Lazygit on Linux and macOS. Lazygit is a simple terminal UI for git commands, written in Go with the gocui library. Lazygit enables you to have a feeling of Sourcetree but in a terminal-centric environment. Lazygit is fast and easy to use, you just need to call lazygit in your terminal inside a git repository. Lazygit can run on Linux, macOS, FreeBSD, and Windows.

Features of Lazygit

Below are the cool features of lazygit:

  • Adding files easily
  • Resolving merge conflicts
  • Easily check out recent branches
  • Scroll through logs/diffs of branches/commits/stash
  • Quick pushing/pulling
  • Squash down and rename commits

Below are the panels available on lazygit git commands UI tool

  • Global Panel
  • Files Panel
  • Branches Panel
  • Commits Panel
  • Stash Panel
  • Diff Panel for resolving Merge conflicts.

How to Install lazygit on macOS

You can easily install lazygit on macOS using brew.

$ brew tap jesseduffield/lazygit
$ brew install lazygitbrew tap

How to Install lazygit on Ubuntu

Lazygit packages for Ubuntu18.04, Ubuntu 16.04 and Ubuntu 18.10 are available via Launchpad PPA. Add it to your Ubuntu system then install lazygit.

sudo add-apt-repository ppa:lazygit-team/daily
sudo apt-get update
sudo apt-get install lazygit

How to install Lazygit on Arch Linux

For Arch Linux users, you can install lazygit from AUR.  There are two packages. The stable one which is built (lazygit) with the latest release and the git version (lazygit-git)which builds from the most recent commit.

To be able to install packages from AUR on Arch Linux, you need an AUR helper. Check yay – Best AUR Helper for Arch Linux / Manjaro. Once you have installed yay, install lazygit like below:

$ yay -S --noconfirm --needed lazygit

For development release, use:

$ yay -S --noconfirm --needed lazygit-git

You can also install lazygit from binary packages. Below is an example of installing lazygit from the binary package in Linux.

export VER="0.1.55"
wget https://github.com/jesseduffield/lazygit/releases/download/v${VER}/lazygit_${VER}_Linux_x86_64.tar.gz -O  lazygit.tgz
tar xvf lazygit.tgz
sudo mv lazygit /usr/local/bin/

How to use lazygit for git commands

Call lazygit in your terminal inside a git repository

$ lazygit

Below are lazygit Keybindings:

Global:

  /hjkl:               navigate
  PgUp/PgDn or ctrl+u/ctrl+d:   scroll diff panel 
                                     (for PgUp and PgDn, use fn+up/fn+down on osx)
  q:                                quit
  p:                                pull
  shift+P:                          push

Files Panel:

  space:    toggle staged
  c:        commit changes
  shift+C: commit using git editor
  shift+S: stash files
  t:        add patched (i.e. pick chunks of a file to add)
  o:        open
  e:        edit
  s:        open in sublime (requires 'subl' command)
  v:        open in vscode (requires 'code' command)
  i:        add to .gitignore
  d:        delete if untracked checkout if tracked (aka go away)
  shift+R: refresh files

Branches Panel:

  space:   checkout branch
  f:       force checkout branch
  m:       merge into currently checked out branch
  c:       checkout by name
  n:       new branch
  d:       delete branch

Commits Panel:

  s:       squash down (only available for topmost commit)
  r:       rename commit
  g:       reset to this commit

Stash Panel:

  space:   apply
  g:       pop
  d:       drop

Popup Panel:

  esc:     close/cancel
  enter:   confirm
  tab:     enter newline (if editing)

Resolving Merge Conflicts (Diff Panel):

  /hl: navigate conflicts
  /kj: select hunk
  space:      pick hunk
  b:         pick both hunks
  z:         undo (only available while still inside diff panel)

Happy lazy git time!.