(Last Updated On: April 29, 2019)

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 Ubuntu 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

Install lazygit from binary package

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

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

Confirm installation.

$ lazygit  -v
commit=63e2ccfccf32bd7fff2e721940f8173c6194cce5, build date=2019-03-05T10:57:25Z, build source=binaryRelease, version=0.7.2, os=linux, arch=amd64

How to use lazygit for git commands

Execute lazygit command in your terminal inside a git repository

$ lazygit

Below are lazygit Keybindings:


 ← →↑↓/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!. Other git related articles include:

Gitleaks – How to Audit git repository for secrets

How to remove git files, directories in .gitignore from a remote repository

How to Configure GitLab FreeIPA LDAP Authentication