Install and Use lazygit – A simple terminal UI for git commands

Posted on 15 views

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.31.4"
wget -O lazygit.tgz$VER/lazygit_$VER_Linux_x86_64.tar.gz
tar xvf lazygit.tgz
sudo mv lazygit /usr/local/bin/

Confirm installation.

$ lazygit  -v
commit=02bf6a5c177c145c46e5e62524458fc3375d01af, build date=2021-11-22T10:08:20Z, build source=binaryRelease, version=0.31.4, 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!


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.