<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Lazygit-tutorial - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Lazygit-tutorial - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 18 May 2026 22:35:12 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/lazygit-tutorial/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Use Lazygit to Improve Your Git Workflow ]]>
                </title>
                <description>
                    <![CDATA[ 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... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-lazygit-to-improve-your-git-workflow/</link>
                <guid isPermaLink="false">67f7cc7aaf72aa46d378eaa0</guid>
                
                    <category>
                        <![CDATA[ Lazygit-tutorial ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Lazygit ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ version control ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Rajdeep Singh ]]>
                </dc:creator>
                <pubDate>Thu, 10 Apr 2025 13:49:46 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1744293114488/5332db88-bff6-4aef-91eb-3423f3b95e1a.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p><a target="_blank" href="https://github.com/jesseduffield/lazygit">Lazygit</a> 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.</p>
<p>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.</p>
<p>In simple terms, Lazygit helps you increase your productivity while working with Git.</p>
<p>In this article, we'll walk through the essential features of Lazygit, and I’ll show you how it works.</p>
<h2 id="heading-table-of-contents">Table of Contents:</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-how-to-install-lazygit">How to Install Lazygit</a></p>
</li>
<li><p><a class="post-section-overview" href="#how-to-use-lazygit">How to Use Lazygit</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcuts-and-key-mappings-in-lazygit">Shortcuts and Key Mappings in Lazygit</a></p>
</li>
<li><p><a class="post-section-overview" href="#other-keybindings-in-lazygit">Other Keybindings in Lazygit</a></p>
</li>
<li><p><a class="post-section-overview" href="#conclusion">Conclusion</a></p>
</li>
</ol>
<h2 id="heading-how-to-install-lazygit">How to Install Lazygit</h2>
<p>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):</p>
<h3 id="heading-homebrew">Homebrew</h3>
<p>You can <a target="_blank" href="https://formulae.brew.sh/formula/lazygit#default">install lazygit</a> in macOS using Homebrew like this:</p>
<pre><code class="lang-bash">brew install lazygit
</code></pre>
<h3 id="heading-scoop-windows">Scoop (Windows)</h3>
<p>You can <a target="_blank" href="https://scoop.sh/#/apps?q=lazygit">install lazygit</a> in Windows using Scoop like this:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Add the extras bucket</span>
scoop bucket add extras

<span class="hljs-comment"># Install lazygit</span>
scoop install lazygit
</code></pre>
<h3 id="heading-arch-linux">Arch Linux</h3>
<p>You can <a target="_blank" href="https://aur.archlinux.org/packages/lazygit-git">install lazygit</a> in Arch using Pacman like this:</p>
<pre><code class="lang-bash">sudo pacman -S lazygit
</code></pre>
<h3 id="heading-ubuntu-and-debian">Ubuntu and Debian</h3>
<p>You can install lazygit in Ubuntu and Debian using the following command:</p>
<pre><code class="lang-bash">LAZYGIT_VERSION=$(curl -s <span class="hljs-string">"https://api.github.com/repos/jesseduffield/lazygit/releases/latest"</span> | \grep -Po <span class="hljs-string">'"tag_name": *"v\K[^"]*'</span>)
curl -Lo lazygit.tar.gz <span class="hljs-string">"https://github.com/jesseduffield/lazygit/releases/download/v<span class="hljs-variable">${LAZYGIT_VERSION}</span>/lazygit_<span class="hljs-variable">${LAZYGIT_VERSION}</span>_Linux_x86_64.tar.gz"</span>
tar xf lazygit.tar.gz lazygit
sudo install lazygit -D -t /usr/<span class="hljs-built_in">local</span>/bin/
</code></pre>
<p>Verify the correct installation of lazygit:</p>
<pre><code class="lang-bash">lazygit --version
</code></pre>
<p>The command output looks like this:</p>
<pre><code class="lang-bash">➜  lazygit --version
commit=, build date=, build <span class="hljs-built_in">source</span>=nix, version=0.44.1, os=linux, arch=amd64, git version=2.47.0
</code></pre>
<h3 id="heading-fedora-and-rhel">Fedora and RHEL</h3>
<p>You can install lazygit in Fedora and RHEL using DNF like this:</p>
<pre><code class="lang-bash">sudo dnf copr <span class="hljs-built_in">enable</span> atim/lazygit -y
sudo dnf install lazygit
</code></pre>
<h3 id="heading-nixos">NixOS</h3>
<p>You can <a target="_blank" href="https://search.nixos.org/packages?channel=24.11&amp;from=0&amp;size=50&amp;sort=relevance&amp;type=packages&amp;query=lazygit">install lazygit</a> in NixOS using the following method:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># with nix-shell</span>
nix-shell -p lazygit

<span class="hljs-comment"># with nix-env</span>
nix-env -iA lazygit

<span class="hljs-comment"># with /etc/nixos/configuration.nix</span>
environment.systemPackages = [
  pkgs.lazygit
];
<span class="hljs-comment"># or with enable lazygit flakes</span>
nix run nixpkgs<span class="hljs-comment">#lazygit</span>
</code></pre>
<h2 id="heading-how-to-use-lazygit">How to Use Lazygit</h2>
<p>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.</p>
<p>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.</p>
<p>To use Lazygit, first open the terminal you use. For example, I’m using the GNOME distro, so I’ll use the <a target="_blank" href="https://gitlab.gnome.org/chergert/ptyxis">Ptyxis terminal</a>.</p>
<p>Type the <code>lazygit</code> command in your terminal:</p>
<pre><code class="lang-bash">lazygit
</code></pre>
<p>The command output should look like this in your terminal:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743685042853/ab3f10f0-0d13-44d3-a86a-a58676cf30a5.gif" alt="Lazygit cli demo" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<p>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:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743687006438/5ca2451e-d4a0-42a7-89b2-0b94fd4ca162.png" alt="Explore the Lazygit panels" class="image--center mx-auto" width="1920" height="1048" loading="lazy"></p>
<h3 id="heading-panels-or-sections-in-lazygit">Panels or Sections in Lazygit</h3>
<p>As I mentioned above, there are six main panels in Lazygit. They are:</p>
<ol>
<li><p>Status</p>
</li>
<li><p>Files</p>
</li>
<li><p>Branches</p>
</li>
<li><p>Commits</p>
</li>
<li><p>Stash</p>
</li>
<li><p>Previews</p>
</li>
</ol>
<p>The most important panels in Lazygit are files, branches, and commits, but we’ll examine each of the six now.</p>
<h4 id="heading-status-panel">Status panel</h4>
<p>The status panel provides an overview of your current repository and the current checked-out branch, including local and remote changes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743759630157/a7ef738b-5353-4941-9eb5-073d3235aaba.png" alt="Status panel in Lazygit" class="image--center mx-auto" width="648" height="98" loading="lazy"></p>
<p>Also, when you click on the status panel text, it opens a new tab or panel where it shows the recently opened repository list.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743760171736/8edb2f41-86ad-4e64-95f2-b1310d8c6f57.png" alt="Recently opened repos" class="image--center mx-auto" width="1920" height="1048" loading="lazy"></p>
<h4 id="heading-files-panel">Files panel</h4>
<p>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.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743760570130/c891940b-4ba2-4fcb-a867-817b74e53618.png" alt="Files panel in Lazygit" class="image--center mx-auto" width="652" height="305" loading="lazy"></p>
<h4 id="heading-branches-panel">Branches panel</h4>
<p>The Branches panel shows lists of local and remote branches which are available in this repository.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743761276628/b34dc945-11c8-482d-8c4d-51783c68bf55.png" alt="Branches panel in lazygit" class="image--center mx-auto" width="649" height="256" loading="lazy"></p>
<h4 id="heading-commits-panel">Commits panel</h4>
<p>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.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743761671236/80a7321a-8d16-4add-bc4a-db52d2987836.png" alt="commits panel in lazygit" class="image--center mx-auto" width="649" height="300" loading="lazy"></p>
<h4 id="heading-stashes-panel">Stashes panel</h4>
<p>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.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743764679570/d7233d92-cfb0-4757-a338-bcc3d9fec2b8.png" alt="Stashes panel in laygit" class="image--center mx-auto" width="650" height="220" loading="lazy"></p>
<h4 id="heading-preview-panel">Preview panel</h4>
<p>The preview panel lets you preview unstaged changes, commits, logs, file content, and so on in Lazygit.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743765844602/7c492361-bbcf-4d2c-8588-b0c3e8704132.png" alt="Preview panel in lazygit" class="image--center mx-auto" width="1920" height="1048" loading="lazy"></p>
<p>To switch between panels, use the left and right arrow keys or the specific keybindings displayed at the top of each panel.</p>
<p>Press <code>1</code> to open the Status panel, <code>2</code> for Files, <code>3</code> for Branches, <code>4</code> for Commits, and <code>5</code> for the Stash panel.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743766590099/91689f4d-eba3-47cf-80a6-e18307c326cd.gif" alt="Navigation between panels in lazygit" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h2 id="heading-shortcuts-and-key-mappings-in-lazygit"><strong>Shortcuts and Key Mappings in Lazygit</strong></h2>
<p>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.</p>
<p>For example, usually when you commit a file, you’ll first add the file using <code>git add</code> and then commit the file using <code>git commit</code>.</p>
<p>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.</p>
<p>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:</p>
<ul>
<li><p><code>a</code> – Stage or unstage all the files available in the Files panel.</p>
</li>
<li><p><code>space</code> (file panel) – Stage or unstage a single file in the Files panel.</p>
</li>
<li><p><code>c</code> – Commit staged changes by opening a commit message editor.</p>
</li>
<li><p><code>p</code> – Push commits to the remote repository.</p>
</li>
<li><p><code>P</code> – Pull changes from the remote repository.</p>
</li>
<li><p><code>z</code> – Undo the commit.</p>
</li>
<li><p><code>s</code> – Stash changes, allowing you to switch branches or perform other operations.</p>
</li>
<li><p><code>S</code> – View and apply stashed changes.</p>
</li>
<li><p><code>n</code> – Create a new branch.</p>
</li>
<li><p><code>d</code> – Delete your branch.</p>
</li>
<li><p><code>y</code> – Copy to clipboard.</p>
</li>
<li><p><code>M</code> – Merge branch.</p>
</li>
<li><p><code>space</code> (branches panel) – Check out the selected target branch.</p>
</li>
<li><p><code>e</code> – Edit or open the file in an external editor.</p>
</li>
<li><p><code>q</code> – Quit Lazygit and return to the terminal.</p>
</li>
<li><p><code>d</code> – Discard any changes in the file.</p>
</li>
<li><p><code>?</code> – Open the keybinding menu.</p>
</li>
</ul>
<p>Now let’s go over these shortcuts so you can understand how they work and see them in action.</p>
<h3 id="heading-how-to-commit-a-file">How to Commit a File</h3>
<p>To commit a file in Lazygit, first select the file you need by pressing the <code>space</code> key or the <code>a</code> key or double-clicking on the file. Then press <code>c</code>, and a new panel should open. There, you can add a message and hit enter to commit the file.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743770682782/cbd83578-a286-482f-aeaa-31a9715a5483.gif" alt="cbd83578-a286-482f-aeaa-31a9715a5483" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h3 id="heading-how-to-pull-and-push-code">How to Pull and Push Code</h3>
<p>To pull remote code from the Git server (Github, GitLab, Gitea, and so on), you can press <code>p</code> (lower case p):</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743774642242/decec44c-7622-432a-9da5-81b14b60ef8a.gif" alt="decec44c-7622-432a-9da5-81b14b60ef8a" class="image--center mx-auto" width="680" height="371" loading="lazy"></p>
<p>To push local code into a Git server, you can press <code>P</code> (upper case P):</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743842516002/37647a76-afe5-4d4b-acfc-fc85f1010749.gif" alt="37647a76-afe5-4d4b-acfc-fc85f1010749" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h3 id="heading-how-to-create-and-delete-a-branch">How to Create and Delete a Branch</h3>
<p>To create a new branch in Lazygit, press <code>n</code>. A new panel will open where you’ll add the name of the branch and hit Enter.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743843881624/6c4db14e-0102-4333-be56-5d3796ab1c50.gif" alt="Create a new branch in lazygit" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<p>To delete a branch, press <code>d</code> 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.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743847541934/34e378b6-03ac-4e6d-93d0-35aaeda39e57.gif" alt="34e378b6-03ac-4e6d-93d0-35aaeda39e57" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<blockquote>
<p>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.</p>
</blockquote>
<h3 id="heading-how-to-undo-a-commit">How to Undo a Commit</h3>
<p>To undo the last commit in Lazygit, just press <code>z</code>. A new panel will open, showing the details of the commit you are undoing. Then, hit Enter.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743852917448/a3f2cab7-2806-48e4-a749-90f821b537dc.gif" alt="Undo commit in lazygit" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h3 id="heading-how-to-merge-a-branch">How to Merge a Branch</h3>
<p>To merge a branch, press <code>M</code> (capital M). To open the merge options, choose the merge type, then hit Enter.</p>
<h4 id="heading-merge-type">Merge type:</h4>
<ul>
<li><p><strong>Merge:</strong> A standard merge, preserving the branch history.</p>
</li>
<li><p><strong>Squash merge:</strong> Combines all commits from the branch into a single commit on the target branch.</p>
</li>
<li><p><strong>Squash merge and leave uncommitted</strong>: Same as squash merge, but leaves the changes uncommitted.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743921595283/e46e0c89-b69a-4462-acd3-295045c99dfd.gif" alt="Merge branch in lazygit" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h3 id="heading-how-to-resolve-merge-conflicts">How to Resolve Merge Conflicts</h3>
<p>To resolve merge conflicts in Lazygit, first merge a branch by pressing <code>M</code>, then choose the merge type (which I describe in the subsection on how to merge a branch) and hit Enter.</p>
<p>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.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743921640247/e5b7f971-f027-47df-be4c-a90b356e24f8.gif" alt="resolve merge conflicts in lazygit" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h3 id="heading-how-to-discard-changes">How to Discard Changes</h3>
<p>To discard or drop any changes in a file or commit, press <code>d</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743774406564/bc5b91fb-2d33-41d0-95b9-667478c4c8db.gif" alt="bc5b91fb-2d33-41d0-95b9-667478c4c8db" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h3 id="heading-how-to-copy">How to Copy</h3>
<p>To copy a file name, path, commit hash, message, URL, author, or any other details, first select the commit or file, then press <code>y</code> to copy the information.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743856793802/e23d9e5c-b0b4-40a0-8124-f94669b377c0.gif" alt="e23d9e5c-b0b4-40a0-8124-f94669b377c0" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h2 id="heading-other-keybindings-in-lazygit">Other Keybindings in Lazygit</h2>
<p>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 <code>?</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743843262905/a4aba097-999b-4ff8-bd00-661181d96aad.gif" alt="a4aba097-999b-4ff8-bd00-661181d96aad" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<p>When you open the keybindings help menu, it changes according to the panel you’re in.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743915037200/9339b7b1-b2a4-45e5-8a51-5be0a9f2a319.gif" alt="9339b7b1-b2a4-45e5-8a51-5be0a9f2a319" class="image--center mx-auto" width="1000" height="545" loading="lazy"></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>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.</p>
<p>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.</p>
<p>To learn more about <a target="_blank" href="https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings/Keybindings_en.md">LazyGit keybindings or shortcuts</a>, you can refer to the Lazygit documentation. You can also check out the following YouTube tutorials for beginners:</p>
<ul>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=A6F_8ajlrYQ">LazyGIt - A Faster, Easier Way to Use Git on Terminal &amp; NeoVim</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=Ihg37znaiBo">Lazygit - The Best Way To Use Git On The Terminal &amp; Neovim</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=06lEP59XAgM">My new favorite way to use Git</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=dSWJKcEiAaM">LazyGit: Effortless Git in Your Terminal!</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
