Why Lazygit is Your New Best Friend in the Terminal
Lazygit is a simple terminal UI (User Interface) for Git commands. Instead of typing out long, complicated Git commands, you can use a single, interactive screen to perform a wide range of actions. Think of it as a friendly, visual layer on top of your existing Git setup.
From a software engineer's perspective, this tool is incredibly helpful for several reasons
Speed and Efficiency
It drastically reduces the number of commands you need to type. You can stage files, commit, push, pull, and even rebase or cherry-pick with just a few keystrokes. This is a massive time-saver, especially for complex operations.
Visual Clarity
Lazygit gives you a clear, at-a-glance view of your repository's status. You can see your branch, commit history, unstaged files, and staged files all in one place. This visual feedback makes it much easier to understand what's happening in your repo.
Reduced Errors
By providing a menu-driven interface, it minimizes the risk of typos and command-line errors. For example, instead of manually typing a commit hash for a rebase, you can simply select it from the list.
Easier Learning Curve
For those who are new to Git or struggle with more advanced commands like interactive rebasing, Lazygit makes these concepts much more approachable. The UI guides you through the process, making it less intimidating.
The installation process is straightforward, and the method depends on your operating system.
macOS (using Homebrew)
If you have Homebrew, you can install it with a single command
brew install lazygit
Linux (using a shell script)
On Linux, you can use the install script
# For Linux
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin
Windows (using Chocolatey or Scoop)
On Windows, you can use a package manager like Chocolatey or Scoop.
With Chocolatey
choco install lazygit
With Scoop
scoop install lazygit
Once installed, simply navigate to your Git repository in the terminal and type lazygit. The UI will pop up instantly.
The "code" in this case is a set of keybindings and actions within the UI. Here's a quick example of a common workflow
Imagine you've made some changes to a file, README.md, and you want to commit it.
The "Old" Way (using standard Git commands)
git add README.md
git commit -m "Update README"
git push
The Lazygit Way
Navigate to your repo in the terminal and type lazygit.
The UI will show your unstaged files. You'll see README.md listed.
Press space on the README.md file to stage it. The file will move to the "Staged Files" section.
Press c to commit. A new window will pop up for you to write your commit message. Type "Update README".
Press enter to finalize the commit.
Press P to push your changes to the remote.
It's that simple! You perform a series of common actions with just a few single-key presses, all from a single screen.
Lazygit has many other powerful features, including
Interactive Rebasing
Press e on a commit in the commits view to begin an interactive rebase.
Branch Management
The branches panel lets you checkout, merge, or rebase from other branches easily.
Stashing
You can stash and unstash changes with simple keybindings.