这是用户在 2025-8-7 22:54 为 https://github.com/jesseduffield/lazygit 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
Skip to content

jesseduffield/lazygit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c0dcf7d · Aug 7, 2025

History

6,777 Commits
Jul 18, 2025
Aug 6, 2025
Jul 18, 2025
Jun 23, 2024
Aug 7, 2023
Aug 1, 2025
Aug 7, 2025
Aug 1, 2025
Jul 18, 2025
Jan 24, 2024
Aug 1, 2025
Aug 28, 2024
Jan 24, 2024
Jul 1, 2024
Aug 1, 2025
Jul 3, 2025
Aug 6, 2025
Jan 18, 2022
Dec 31, 2024
Mar 9, 2025
Aug 5, 2018
Jul 18, 2025
Aug 3, 2025
Dec 31, 2024
Aug 1, 2025
Aug 1, 2025
Aug 13, 2022

Repository files navigation

A simple terminal UI for git commands
一个简单的终端 Git 命令界面

GitHub Releases Go Report Card Codacy Badge Codacy Badge GolangCI GitHub tag homebrew

Sponsors  赞助者

Maintenance of this project is made possible by all the contributors and sponsors. If you'd like to sponsor this project and have your avatar or company logo appear below click here. 💙
该项目的维护得益于所有贡献者和赞助者的支持。如果您想赞助该项目,并希望您的头像或公司标志出现在下方,请点击这里。💖

Mark LussierDean HerbertPeter BjorklundReilly WoodOliver GüntherPawan DhananjayBartłomiej DachCarsten GehlingCEUKHolden LucasChau TranmatejciktheAverageDev (Luca Tumedei)Nicholas CloudAliaksandr StelmachonakBurgy BenjaminJoe KlemmerTobias LütkeBen BeaumontHollyCasey BoettcherJeff ForcierMaciej T. NowakYuryAndreas KurthBraden SteffaniakJordan GillardSebastianAndy SlezakMartin KockJesse AlamaDaniel KokottJan HeijmansKevin NowaldOmar LuqEthan LiMaxiJan ZenknerFrederick MorlockMaximilian LangenfeldDavis BulsNeil LambertDavid Heinemeier HanssonEthan FischerTerry TaiAdam RoesnerTim MorganMax ShypulniakKovács ÁdámPatricio SerranoKiriBob ParsonsJohn Even BjørnevikMichael OberstStian HegglundAdam TrepanierKenth FagerlundJulien TardotAaron ArredondoEllord TayagEdgar Post-Buijssbc64Pierre SpringZac ClayThomas MüllerCarl AssmannSergey OgnevMoody LiuAlex GMichael HowardLasse Bloch LauritsenLarry MarburgerDavid BrockmanAlexander SlavschikAidan GaulandMaksym BieńkowskiJoshua WootonnGurbinder SinghSimon Sandvik LeeThomas GilbertSzymon MuchaTim ShilovUnnawut LeepaisalsuwannaBret WortmanAndré LameirinhasScott VelezjustinAusten BolithoMantasMayfield

Elevator Pitch  电梯演讲

Rant time: You've heard it before, git is powerful, but what good is that power when everything is so damn hard to do? Interactive rebasing requires you to edit a goddamn TODO file in your editor? Are you kidding me? To stage part of a file you need to use a command line program to step through each hunk and if a hunk can't be split down any further but contains code you don't want to stage, you have to edit an arcane patch file by hand? Are you KIDDING me?! Sometimes you get asked to stash your changes when switching branches only to realise that after you switch and unstash that there weren't even any conflicts and it would have been fine to just checkout the branch directly? YOU HAVE GOT TO BE KIDDING ME!
吐槽时间:你肯定听过,git 很强大,但这种强大有什么用,当一切操作都如此难的时候?交互式重基需要你在编辑器中编辑一个该死的 TODO 文件?你在开玩笑吗?要暂存文件的一部分,你需要使用命令行程序逐个处理每个块,如果一个块不能再分割,但包含你不想要暂存的代码,你只能手动编辑一个晦涩的补丁文件?你在逗我吗?有时候你被要求在切换分支时暂存更改,结果切换分支并恢复后发现根本没有冲突,直接切换分支就好了?你一定是在逗我!

If you're a mere mortal like me and you're tired of hearing how powerful git is when in your daily life it's a powerful pain in your ass, lazygit might be for you.
如果你像我一样只是一个普通人,每天使用 git 时发现它虽然强大却常常给你带来麻烦,那么 lazygit 可能会适合你。

Table of contents  目录

Lazygit is not my fulltime job but it is a hefty part time job so if you want to support the project please consider sponsoring me
Lazygit 并不是我的全职工作,但它是一项重要的兼职工作,所以如果你想要支持这个项目,请考虑赞助我

Features  特性

Stage individual lines  单独暂存行

Press space on the selected line to stage it, or press v to start selecting a range of lines. You can also press a to select the entirety of the current hunk.
在选中的行上按下空格键可以暂存该行,或者按下 v 可以开始选择一系列行。你也可以按下 a 选择当前块的所有内容。

Interactive Rebase 重试    错误原因

Press i to start an interactive rebase. Then squash (s), fixup (f), drop (d), edit (e), move up (ctrl+k) or move down (ctrl+j) any of TODO commits, before continuing the rebase by bringing up the rebase options menu with m and then selecting continue. 重试    错误原因

You can also perform any these actions as a once-off (e.g. pressing s on a commit to squash it) without explicitly starting a rebase. 重试    错误原因

This demo also uses shift+down to select a range of commits to move and fixup.
这个示例还使用 shift+down 选择一系列提交进行移动和修复。

Cherry-pick

Press shift+c on a commit to copy it and press shift+v to paste (cherry-pick) it.
在提交上按 shift+c 复制它,然后按 shift+v 粘贴(cherry-pick)。

Bisect  二义性查找

Press b in the commits view to mark a commit as good/bad in order to begin a git bisect. 重试    错误原因

Nuke the working tree  清空工作目录

For when you really want to just get rid of anything that shows up when you run git status (and yes that includes dirty submodules) kidpix style, press shift+d to bring up the reset options menu and then select the 'nuke' option.
当你真的想清除运行 git status 时显示的所有内容(包括未清理的子模块)时,可以按下 shift+d 弹出重置选项菜单,然后选择“清空”选项。

Amend an old commit  修改旧的提交

Pressing shift+a on any commit will amend that commit with the currently staged changes (running an interactive rebase in the background).
按下 shift+a 可以将当前已暂存的更改合并到任意提交中(后台运行交互式重基操作)。

Filter

You can filter a view with /. Here we filter down our branches view and then hit enter to view its commits.
你可以使用 / 进行过滤。在这里,我们将分支视图进行过滤,然后按下 enter 查看其提交记录。

Invoke a custom command  调用自定义命令

Lazygit has a very flexible custom command system. In this example a custom command is defined which emulates the built-in branch checkout action.
Lazygit 具有非常灵活的自定义命令系统。在这个示例中,定义了一个自定义命令,该命令模拟了内置分支切换操作。

Worktrees

You can create worktrees to have multiple branches going at once without the need for stashing or creating WIP commits when switching between them. Press w in the branches view to create a worktree from the selected branch and switch to it.
你可以创建 worktrees,在切换分支时无需 stash 或创建 WIP 提交即可同时处理多个分支。在分支视图中按下 w 即可从选定的分支创建 worktree 并切换到该分支。

Rebase magic (custom patches)
重新应用魔法(自定义补丁)

You can build a custom patch from an old commit and then remove the patch from the commit, split out a new commit, apply the patch in reverse to the index, and more.
你可以从一个旧提交构建一个自定义补丁,然后从提交中移除该补丁,拆分出一个新的提交,将补丁反向应用到索引中,等等。

In this example we have a redundant comment that we want to remove from an old commit. We hit <enter> on the commit to view its files, then <enter> on a file to focus the patch, then <space> to add the comment line to our custom patch, and then ctrl+p to view the custom patch options; selecting to remove the patch from the current commit.
在本示例中,我们有一个多余的注释,想要从一个旧提交中移除。我们按下 <enter> 查看提交的文件,然后按下 <enter> 选择一个文件来聚焦补丁,接着按下 <space> 将注释行添加到自定义补丁中,然后按下 ctrl+p 查看自定义补丁选项;选择从当前提交中移除该补丁。

Learn more in the Rebase magic Youtube tutorial.
了解更多关于重 base 魔法的 YouTube 教程。

Rebase from marked base commit
从标记的基础提交进行重新整理

Say you're on a feature branch that was itself branched off of the develop branch, and you've decided you'd rather be branching off the master branch. You need a way to rebase only the commits from your feature branch. In this demo we check to see which was the last commit on the develop branch, then press shift+b to mark that commit as our base commit, then press r on the master branch to rebase onto it, only bringing across the commits from our feature branch. Then we push our changes with shift+p.
在你处于一个特性分支上时,这个特性分支又是从 develop 分支派生出来的,而你决定改为从 master 分支进行分支。你需要一种方法来仅重新应用特性分支中的提交。在本演示中,我们首先检查 develop 分支的最后一个提交,然后按下 shift+b 标记该提交作为基点,接着在 master 分支上按下 r 来重新应用到该基点,仅带来特性分支中的提交。然后我们使用 shift+p 推送更改。

Undo  撤销

You can undo the last action by pressing z and redo with ctrl+z. Here we drop a couple of commits and then undo the actions. Undo uses the reflog which is specific to commits and branches so we can't undo changes to the working tree or stash.
您可以按 z 撤销上一个操作,按 ctrl+z 重新执行。这里我们丢弃了几条提交,然后撤销了这些操作。撤销使用的是 reflog,这是针对提交和分支的,因此我们无法撤销工作树中的更改或 stash。

More info  更多信息

Commit graph  提交图

When viewing the commit graph in an enlarged window (use + and _ to cycle screen modes), the commit graph is shown. Colours correspond to the commit authors, and as you navigate down the graph, the parent commits of the selected commit are highlighted.
在放大窗口中查看提交图(使用 +_ 切换屏幕模式时),将显示提交图。颜色对应于提交作者,当你在图中导航时,所选提交的父提交将被高亮显示。

Compare two commits  比较两个提交

If you press shift+w on a commit (or branch/ref) a menu will open that allows you to mark that commit so that any other commit you select will be diffed against it. Once you've selected the second commit, you'll see the diff in the main view and if you press <enter> you'll see the files of the diff. You can press shift+w to view the diff menu again to see options like reversing the diff direction or exiting diff mode. You can also exit diff mode by pressing <escape>.
如果你在某个提交(或分支/引用)上按下 shift+w ,将会弹出一个菜单,允许你标记该提交,以便在选择另一个提交时将其与该提交进行比较。一旦你选择了第二个提交,你将在主视图中看到差异,并且按下 <enter> 可以查看差异的文件。你可以按下 shift+w 再次查看差异菜单,以查看如反转差异方向或退出差异模式等选项。你也可以通过按下 <escape> 退出差异模式。

Tutorials  教程

Installation  安装

Packaging status

Most of the above packages are maintained by third parties so be sure to vet them yourself and confirm that the maintainer is a trustworthy looking person who attends local sports games and gives back to their communities with barbeque fundraisers etc
大多数上述软件包由第三方维护,因此请务必自行核实,并确认维护者是一个看起来值得信赖的人,他们参加当地的体育赛事,并通过烧烤筹款等活动回馈社区

For Windows, Mac OS(10.12+) or Linux, you can download a binary release here. 重试    错误原因

It works with Linux, too.
它同样适用于 Linux。

brew install lazygit

MacPorts

Latest version built from github releases. Tap:
最新版本是从 github 发布构建的。Tap:

sudo port install lazygit

Void Linux

Packages for Void Linux are available in the distro repo
Void Linux 的软件包在发行版仓库中可用

They follow upstream latest releases 重试    错误原因

sudo xbps-install -S lazygit

Scoop (Windows)

You can install lazygit using scoop. It's in the extras bucket:
你可以使用 scoop 安装 lazygit 。它在 extras 桶中:

# Add the extras bucket
scoop bucket add extras

# Install lazygit
scoop install lazygit

Arch Linux

Packages for Arch Linux are available via pacman and AUR (Arch User Repository).
Arch Linux 的软件包可以通过 pacman 和 AUR(Arch User Repository)获取。

There are two packages. The stable one which is built with the latest release and the git version which builds from the most recent commit.
有两个软件包。一个是基于最新发布版本的稳定版本,另一个是基于最近提交的 git 版本。

Instruction of how to install AUR content can be found here: https://wiki.archlinux.org/index.php/Arch_User_Repository
如何安装 AUR 内容的说明可以在以下链接找到:https://wiki.archlinux.org/index.php/Arch_User_Repository

Fedora / Amazon Linux 2023 / CentOS Stream

Packages for Fedora, Amazon Linux 2023 and CentOS Stream are available via Copr (Cool Other Package Repo).
适用于 Fedora、Amazon Linux 2023 和 CentOS Stream 的包可以通过 Copr(Cool Other Package Repo)获取。

sudo dnf copr enable dejan/lazygit
sudo dnf install lazygit

These packages are built using the RPM spec file located here: https://codeberg.org/dejan/rpm-lazygit
这些包是使用这里提供的 RPM spec 文件构建的:https://codeberg.org/dejan/rpm-lazygit

You should be able to build RPMs for Fedora 41 or older, and other Fedora derivatives using the SRPM (Source RPM) file that you can grab from the latest COPR build.
你应该能够使用从最新 COPR 构建中获取的 SRPM(源 RPM)文件为 Fedora 41 或更早版本以及其他 Fedora 衍生版本构建 RPM 包。

Solus Linux

sudo eopkg install lazygit

Debian and Ubuntu  Debian 和 Ubuntu

For Debian 13 "Trixie", Sid, and later, or Ubuntu 25.10 "Questing Quokka" and later:
对于 Debian 13 "Trixie"、Sid 及更晚版本,或 Ubuntu 25.10 "Questing Quokka" 及更晚版本:

sudo apt install lazygit

For Debian 12 "Bookworm", Ubuntu 25.04 "Plucky Puffin" and earlier:
对于 Debian 12 "Bookworm"、Ubuntu 25.04 "Plucky Puffin" 及更早版本:

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/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 的正确安装:

lazygit --version

Funtoo Linux

Funtoo Linux has an autogenerated lazygit package in dev-kit:
Funtoo Linux 有一个由系统自动生成的 lazygit 包在 dev-kit 中:

sudo emerge dev-vcs/lazygit

Gentoo Linux

Lazygit is not (yet) in main Gentoo portage, however an ebuild is available in GURU overlay
Lazygit 尚未(还未)在 Gentoo 主端口(portage)中,但是 GURU 覆盖(overlay)中有一个 ebuild

You can either add the overlay to your system and install lazygit as usual:
你可以将覆盖层添加到你的系统中,然后像往常一样安装 lazygit:

sudo eselect repository enable guru
sudo emaint sync -r guru
sudo emerge dev-vcs/lazygit

openSUSE

The lazygit package is currently built in devel:languages:go/lazygit.
lazygit 包当前在 devel:languages:go/lazygit 中构建。

To install lazygit on openSUSE Tumbleweed run:
要在 openSUSE Tumbleweed 上安装 lazygit,请运行:

sudo zypper ar https://download.opensuse.org/repositories/devel:/languages:/go/openSUSE_Factory/devel:languages:go.repo
sudo zypper ref && sudo zypper in lazygit

To install lazygit on openSUSE Leap run:
要在 openSUSE Leap 上安装 lazygit,请运行:

source /etc/os-release
sudo zypper ar https://download.opensuse.org/repositories/devel:/languages:/go/$VERSION_ID/devel:languages:go.repo
sudo zypper ref && sudo zypper in lazygit

NixOs

On NixOs lazygit is packaged with nix and distributed via nixpkgs. You can try the lazygit without installing it with:
在 NixOs 中,lazygit 会与 nix 一起打包并通过 nixpkgs 分发。你可以通过以下命令尝试使用 lazygit 而无需安装:

nix-shell -p lazygit
# or with flakes enabled
nix run nixpkgs#lazygit

Or you can add lazygit to you configuration.nix using the environment.systemPackages option. More details can be found via NixOs search page.
或者你可以使用 configuration.nix 选项将 lazygit 添加到你的 environment.systemPackages 中。更多详细信息可以在 NixOs 搜索页面找到。

Flox

Lazygit can be installed into a Flox environment as follows.
Lazygit 可以安装到 Flox 环境中,具体操作如下。

flox install lazygit

More details about Flox can be found on their website.
更多关于 Flox 的详细信息可以在其网站上找到。

FreeBSD

pkg install lazygit

Termux

apt install lazygit

Conda

Released versions are available for different platforms, see https://anaconda.org/conda-forge/lazygit
已发布的版本可在不同平台获取,请参见 https://anaconda.org/conda-forge/lazygit

conda install -c conda-forge lazygit

Go

go install github.com/jesseduffield/lazygit@latest

Please note: If you get an error claiming that lazygit cannot be found or is not defined, you may need to add ~/go/bin to your $PATH (MacOS/Linux), or %HOME%\go\bin (Windows). Not to be mistaken for C:\Go\bin (which is for Go's own binaries, not apps like lazygit).
请注意:如果您遇到 lazygit 未找到或未定义的错误,请尝试在 $PATH 中添加 ~/go/bin (MacOS/Linux),或 %HOME%\go\bin (Windows)。这与 C:\Go\bin (Go 自身的二进制文件所用,而不是像 lazygit 这样的应用程序)不同。

Chocolatey (Windows)  Chocolatey(Windows)

You can install lazygit using Chocolatey:
你可以使用 Chocolatey 安装 lazygit

choco install lazygit

Winget (Windows 10 1709 or later)
Winget(Windows 10 1709 及以上版本)

You can install lazygit using the winget command in the Windows Terminal with the following command:
你可以在 Windows 终端中使用 winget 命令安装 lazygit

winget install -e --id=JesseDuffield.lazygit

Manual  手动

You'll need to install Go
你需要安装 Go

git clone https://github.com/jesseduffield/lazygit.git
cd lazygit
go install

You can also use go run main.go to compile and run in one go (pun definitely intended)
你也可以使用 go run main.go 一次性编译并运行(双关无疑)

Usage  用法

Call lazygit in your terminal inside a git repository.
在 Git 仓库的终端中调用 lazygit

$ lazygit

If you want, you can also add an alias for this with echo "alias lg='lazygit'" >> ~/.zshrc (or whichever rc file you're using).
如果你想的话,你也可以通过 echo "alias lg='lazygit'" >> ~/.zshrc (或你正在使用的任何其他 rc 文件)添加一个别名。

Keybindings  快捷键

You can check out the list of keybindings here.
你可以在这里查看快捷键列表。

Changing Directory On Exit
退出时更改目录

If you change repos in lazygit and want your shell to change directory into that repo on exiting lazygit, add this to your ~/.zshrc (or other rc file):
如果你在 lazygit 中切换了仓库,并希望退出 lazygit 时 shell 也切换到该仓库目录,可以在你的 ~/.zshrc (或其他 rc 文件)中添加以下内容:

lg()
{
    export LAZYGIT_NEW_DIR_FILE=~/.lazygit/newdir

    lazygit "$@"

    if [ -f $LAZYGIT_NEW_DIR_FILE ]; then
            cd "$(cat $LAZYGIT_NEW_DIR_FILE)"
            rm -f $LAZYGIT_NEW_DIR_FILE > /dev/null
    fi
}

Then source ~/.zshrc and from now on when you call lg and exit you'll switch directories to whatever you were in inside lazygit. To override this behaviour you can exit using shift+Q rather than just q.
这样,从现在起当你调用 lg 并退出时,会切换到你在 lazygit 内部所在的目录。如果你想覆盖这种行为,可以在退出时使用 shift+Q 而不是仅仅使用 q

Undo/Redo  撤销/重做

See the docs  查看文档

Configuration  配置

Check out the configuration docs.
查看配置文档。

Custom Pagers  自定义分页器

See the docs  查看文档

Custom Commands  自定义命令

If lazygit is missing a feature, there's a good chance you can implement it yourself with a custom command!
如果 lazygit 缺少某个功能,有很大可能是你可以通过自定义命令来实现它!

See the docs  查看文档

Git flow support  支持 git 流程

Lazygit supports Gitflow if you have it installed. To understand how the Gitflow model works check out Vincent Driessen's original post explaining it. To view Gitflow options from within Lazygit, press i from within the branches view.
Lazygit 支持 Gitflow,前提是您已经安装了 Gitflow。要了解 Gitflow 模型的工作原理,请参阅 Vincent Driessen 的原始文章,其中解释了该模型。要在 Lazygit 中查看 Gitflow 选项,请在分支视图中按 i

Contributing  贡献

We love your input! Please check out the contributing guide. For contributor discussion about things not better discussed here in the repo, join the discord channel
我们非常欢迎您的输入!请查阅贡献指南。对于不适合在此仓库中讨论的贡献者讨论,请加入 Discord 频道。

Check out this video walking through the creation of a small feature in lazygit if you want an idea of where to get started.
查看这个视频,了解如何在 lazygit 中创建一个小功能,这将帮助你了解从何处开始。

Debugging Locally  本地调试

Run lazygit --debug in one terminal tab and lazygit --logs in another to view the program and its log output side by side
在一个终端标签页中运行 lazygit --debug ,在另一个标签页中运行 lazygit --logs ,以并排查看程序及其日志输出

Donate  捐赠

If you would like to support the development of lazygit, consider sponsoring me (github is matching all donations dollar-for-dollar for 12 months)
如果您想支持 lazygit 的开发,可以考虑赞助我(GitHub 会逐美元匹配匹配捐赠金额进行 1 1 至 11 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 个月)

FAQ  常见问题

What do the commit colors represent?
为什么提交的颜色 会不同?

  • Green: the commit is included in the master branch
    绿色:表示提交的 master 分支 是 master 主 分支
  • Yellow: the commit is not included in the master branch
    黄色:该提交未包含在 master 分支中
  • Red: the commit has not been pushed to the upstream branch
    红色:该提交尚未推送到上游分支

Shameless Plug  无耻自荐

If you want to see what I (Jesse) am up to in terms of development, follow me on twitter or check out my blog
如果你想了解我在开发方面的最新动态,可以关注我的 Twitter 或访问我的博客

Alternatives  替代方案

If you find that lazygit doesn't quite satisfy your requirements, these may be a better fit:
如果你发现 lazygit 不能完全满足你的需求,以下这些可能更适合你:

About

simple terminal UI for git commands
简单的终端 UI 用于 git 命令

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

lazygit/docs at master · jesseduffield/lazygit · GitHub