Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 1, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 1, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 1, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 1, 2025

      7 MagSafe accessories that I recommend every iPhone user should have

      June 1, 2025

      I replaced my Kindle with an iPad Mini as my ebook reader – 8 reasons why I don’t regret it

      June 1, 2025

      Windows 11 version 25H2: Everything you need to know about Microsoft’s next OS release

      May 31, 2025

      Elden Ring Nightreign already has a duos Seamless Co-op mod from the creator of the beloved original, and it’ll be “expanded on in the future”

      May 31, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Student Record Android App using SQLite

      June 1, 2025
      Recent

      Student Record Android App using SQLite

      June 1, 2025

      When Array uses less memory than Uint8Array (in V8)

      June 1, 2025

      Laravel 12 Starter Kits: Definite Guide Which to Choose

      June 1, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Photobooth is photobooth software for the Raspberry Pi and PC

      June 1, 2025
      Recent

      Photobooth is photobooth software for the Raspberry Pi and PC

      June 1, 2025

      Le notizie minori del mondo GNU/Linux e dintorni della settimana nr 22/2025

      June 1, 2025

      Rilasciata PorteuX 2.1: Novità e Approfondimenti sulla Distribuzione GNU/Linux Portatile Basata su Slackware

      June 1, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to Use Lazygit to Improve Your Git Workflow

    How to Use Lazygit to Improve Your Git Workflow

    April 10, 2025
    How to Use Lazygit to Improve Your Git Workflow

    Lazygit is an open-source command line terminal UI for Git commands that I’ve used for the last couple of years, and it’s become my new best friend.

    Basically, the Lazygit tool is a wrapper for the Git command line that replaces it with a UI. Instead of typing out Git commands again and again in your terminal, you can use keyboard shortcuts to commit, push, pull, create, edit, and delete branches in your project.

    In simple terms, Lazygit helps you increase your productivity while working with Git.

    In this article, we’ll walk through the essential features of Lazygit, and I’ll show you how it works.

    Table of Contents:

    1. How to Install Lazygit

    2. How to Use Lazygit

    3. Shortcuts and Key Mappings in Lazygit

    4. Other Keybindings in Lazygit

    5. Conclusion

    How to Install Lazygit

    Before we start, you’ll need to make sure it’s installed on your machine. You can install the tool in your system using the following methods (depending on your system):

    Homebrew

    You can install lazygit in macOS using Homebrew like this:

    brew install lazygit
    

    Scoop (Windows)

    You can install lazygit in Windows using Scoop like this:

    # Add the extras bucket
    scoop bucket add extras
    
    # Install lazygit
    scoop install lazygit
    

    Arch Linux

    You can install lazygit in Arch using Pacman like this:

    sudo pacman -S lazygit
    

    Ubuntu and Debian

    You can install lazygit in Ubuntu and Debian using the following command:

    LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": *"vK[^"]*')
    curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/download/v${LAZYGIT_VERSION}/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
    tar xf lazygit.tar.gz lazygit
    sudo install lazygit -D -t /usr/local/bin/
    

    Verify the correct installation of lazygit:

    lazygit --version
    

    The command output looks like this:

    ➜  lazygit --version
    commit=, build date=, build source=nix, version=0.44.1, os=linux, arch=amd64, git version=2.47.0
    

    Fedora and RHEL

    You can install lazygit in Fedora and RHEL using DNF like this:

    sudo dnf copr enable atim/lazygit -y
    sudo dnf install lazygit
    

    NixOS

    You can install lazygit in NixOS using the following method:

    # with nix-shell
    nix-shell -p lazygit
    
    # with nix-env
    nix-env -iA lazygit
    
    # with /etc/nixos/configuration.nix
    environment.systemPackages = [
      pkgs.lazygit
    ];
    # or with enable lazygit flakes
    nix run nixpkgs#lazygit
    

    How to Use Lazygit

    To use Lazygit, you don’t need any advanced knowledge about Lazygit or the Git CLI. If you are a beginner, that’s okay – I’ll walk you through the process and the basics here.

    The main thing to understand is how the key mappings (shortcut keys) work. In this tutorial, I won’t discuss every key mapping, but I’ll teach you about some of the most common Lazygit key mappings which you’ll use on a daily basis. They’ll help you build a solid base for using the tool effectively.

    To use Lazygit, first open the terminal you use. For example, I’m using the GNOME distro, so I’ll use the Ptyxis terminal.

    Type the lazygit command in your terminal:

    lazygit
    

    The command output should look like this in your terminal:

    Lazygit cli demo

    The Lazygit UI is divided into six panels, or sections. Each panel serves a specific use case. Let’s explore these panels in more detail. You can see them highlighted in the image below:

    Explore the Lazygit panels

    Panels or Sections in Lazygit

    As I mentioned above, there are six main panels in Lazygit. They are:

    1. Status

    2. Files

    3. Branches

    4. Commits

    5. Stash

    6. Previews

    The most important panels in Lazygit are files, branches, and commits, but we’ll examine each of the six now.

    Status panel

    The status panel provides an overview of your current repository and the current checked-out branch, including local and remote changes.

    Status panel in Lazygit

    Also, when you click on the status panel text, it opens a new tab or panel where it shows the recently opened repository list.

    Recently opened repos

    Files panel

    The Files panel shows lists of the files in your repository that have been modified or changed. You can see files that you’ve deleted or discarded and unstaged.

    Files panel in Lazygit

    Branches panel

    The Branches panel shows lists of local and remote branches which are available in this repository.

    Branches panel in lazygit

    Commits panel

    The Commits panel shows a list of commits in the current branch, which allows you to view, checkout, or interact with (view/undo/and so on) specific commits.

    Hostinger

    commits panel in lazygit

    Stashes panel

    The Stashes panel helps you manage your stashed changes, allowing you to apply, drop, or view them. Git stash is a location for storing uncommitted changes (modified, staged, or untracked files) in a hidden place, letting you switch branches without committing or discarding them.

    Stashes panel in laygit

    Preview panel

    The preview panel lets you preview unstaged changes, commits, logs, file content, and so on in Lazygit.

    Preview panel in lazygit

    To switch between panels, use the left and right arrow keys or the specific keybindings displayed at the top of each panel.

    Press 1 to open the Status panel, 2 for Files, 3 for Branches, 4 for Commits, and 5 for the Stash panel.

    Navigation between panels in lazygit

    Shortcuts and Key Mappings in Lazygit

    Lazygit is especially popular because of its shortcuts. You don’t need to write the same Git commands in the terminal over and over. Rather, you just need to use a shortcut.

    For example, usually when you commit a file, you’ll first add the file using git add and then commit the file using git commit.

    But in Lazygit, you just have to select the file using your mouse or the up and down keys and press space to commit the file.

    In Lazygit, everything works around the shortcut commands, and you use shortcuts to perform common Git operations. Here are a few essential commands we’ll go over in this tutorial:

    • a – Stage or unstage all the files available in the Files panel.

    • space (file panel) – Stage or unstage a single file in the Files panel.

    • c – Commit staged changes by opening a commit message editor.

    • p – Push commits to the remote repository.

    • P – Pull changes from the remote repository.

    • z – Undo the commit.

    • s – Stash changes, allowing you to switch branches or perform other operations.

    • S – View and apply stashed changes.

    • n – Create a new branch.

    • d – Delete your branch.

    • y – Copy to clipboard.

    • M – Merge branch.

    • space (branches panel) – Check out the selected target branch.

    • e – Edit or open the file in an external editor.

    • q – Quit Lazygit and return to the terminal.

    • d – Discard any changes in the file.

    • ? – Open the keybinding menu.

    Now let’s go over these shortcuts so you can understand how they work and see them in action.

    How to Commit a File

    To commit a file in Lazygit, first select the file you need by pressing the space key or the a key or double-clicking on the file. Then press c, and a new panel should open. There, you can add a message and hit enter to commit the file.

    cbd83578-a286-482f-aeaa-31a9715a5483

    How to Pull and Push Code

    To pull remote code from the Git server (Github, GitLab, Gitea, and so on), you can press p (lower case p):

    decec44c-7622-432a-9da5-81b14b60ef8a

    To push local code into a Git server, you can press P (upper case P):

    37647a76-afe5-4d4b-acfc-fc85f1010749

    How to Create and Delete a Branch

    To create a new branch in Lazygit, press n. A new panel will open where you’ll add the name of the branch and hit Enter.

    Create a new branch in lazygit

    To delete a branch, press d and then specify whether you want to delete the branch in a local or remote repository. In the following example, I’m deleting a local branch.

    34e378b6-03ac-4e6d-93d0-35aaeda39e57

    Note: To delete and create a new branch in Lazygit, first select the branch panel and then press the corresponding shortcut key for deleting a branch. Press the d key to delete, and then to create a branch press the n key. Otherwise, it won’t work.

    How to Undo a Commit

    To undo the last commit in Lazygit, just press z. A new panel will open, showing the details of the commit you are undoing. Then, hit Enter.

    Undo commit in lazygit

    How to Merge a Branch

    To merge a branch, press M (capital M). To open the merge options, choose the merge type, then hit Enter.

    Merge type:

    • Merge: A standard merge, preserving the branch history.

    • Squash merge: Combines all commits from the branch into a single commit on the target branch.

    • Squash merge and leave uncommitted: Same as squash merge, but leaves the changes uncommitted.

    Merge branch in lazygit

    How to Resolve Merge Conflicts

    To resolve merge conflicts in Lazygit, first merge a branch by pressing M, then choose the merge type (which I describe in the subsection on how to merge a branch) and hit Enter.

    If any merge conflicts occur, the conflicting file(s) appear in the files panel. Press Enter to view the merge conflicts in the preview panel and navigate between conflicts using the up and down keys. Select the correct merge conflicts, press the space key, and your merge issue will be resolved.

    resolve merge conflicts in lazygit

    How to Discard Changes

    To discard or drop any changes in a file or commit, press d.

    bc5b91fb-2d33-41d0-95b9-667478c4c8db

    How to Copy

    To copy a file name, path, commit hash, message, URL, author, or any other details, first select the commit or file, then press y to copy the information.

    e23d9e5c-b0b4-40a0-8124-f94669b377c0

    Other Keybindings in Lazygit

    There are other keybindings in Lazygit which I did not discuss in this article. To learn about every keybinding, you can check out the keybindings menu. Open the keybindings menu and press the ?.

    a4aba097-999b-4ff8-bd00-661181d96aad

    When you open the keybindings help menu, it changes according to the panel you’re in.

    9339b7b1-b2a4-45e5-8a51-5be0a9f2a319

    Conclusion

    Lazygit helps you become more productive when working with Git or Git commands. As a beginner, starting with Lazygit can be somewhat challenging because of its key mappings, but once you get the hang of them, they’re pretty easy to remember and use.

    If you are a first-time Lazygit user, my suggestion is to avoid using Lazygit on a working repository. Instead, create a demo repository and try it out/practice.

    To learn more about LazyGit keybindings or shortcuts, you can refer to the Lazygit documentation. You can also check out the following YouTube tutorials for beginners:

    • LazyGIt – A Faster, Easier Way to Use Git on Terminal & NeoVim

    • Lazygit – The Best Way To Use Git On The Terminal & Neovim

    • My new favorite way to use Git

    • LazyGit: Effortless Git in Your Terminal!

    Source: freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHow to Extend the Django User Model
    Next Article Vampire Survivors stealth-launches Emerald Diorama DLC, but PlayStation cross-save looks unlikely

    Related Posts

    Artificial Intelligence

    Markus Buehler receives 2025 Washington Award

    June 1, 2025
    Artificial Intelligence

    LWiAI Podcast #201 – GPT 4.5, Sonnet 3.7, Grok 3, Phi 4

    June 1, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Japanese Man Arrested for GenAI Ransomware as AI Jailbreak Concerns Grow

    Development

    The Photos app is now actually useful thanks to Microsoft’s latest update

    Operating Systems
    Elon Musk got roasted in Path of Exile 2 livestream — He rage-quit after dying over and over

    Elon Musk got roasted in Path of Exile 2 livestream — He rage-quit after dying over and over

    News & Updates

    Brisa 0.2.7 Release notes

    Development

    Highlights

    CVE-2025-3481 – MedDream PACS Server DICOM File Parsing Remote Code Execution Vulnerability

    May 22, 2025

    CVE ID : CVE-2025-3481

    Published : May 22, 2025, 1:15 a.m. | 1 hour, 35 minutes ago

    Description : MedDream PACS Server DICOM File Parsing Stack-based Buffer Overflow Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of MedDream PACS Server. Authentication is not required to exploit this vulnerability.

    The specific flaw exists within the parsing of DICOM files. The issue results from the lack of proper validation of the length of user-supplied data prior to copying it to a fixed-length stack-based buffer. An attacker can leverage this vulnerability to execute code in the context of the service account. Was ZDI-CAN-25827.

    Severity: 9.8 | CRITICAL

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    20+ Best Paper & Newspaper Background Textures

    June 27, 2024

    Marketing AI Conference (MAICON) 2024: accelerating AI adoption in marketing

    August 16, 2024

    Development Release: Ubuntu 25.04 Beta

    March 27, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.