lazygit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Lazygit

Lazygit

Lazygit is a TUI for Git. It makes complex operations (interactive rebase, partial staging) accessible via intuitive keyboard shortcuts.
Lazygit 是一款面向Git的TUI(终端用户界面)工具。它通过直观的键盘快捷键,让复杂的Git操作(如交互式变基、部分暂存)变得易于操作。

When to Use

使用场景

  • Staging: Staging individual lines/hunks (
    Space
    ).
  • Rebasing: Drag-and-drop commits to reorder them (via keybindings).
  • Conflict Resolution: A clear 3-way view to pick "Ours" or "Theirs".
  • 暂存:暂存单独的代码行/代码块(按
    Space
    键)。
  • 变基:通过快捷键拖放提交记录来重新排序。
  • 冲突解决:清晰的三方对比视图,可选择“我方版本”或“对方版本”。

Core Concepts

核心概念

Panels

面板

Status, Files, Local Branches, Commits, Stash. Navigate with
h/l
or arrows.
状态、文件、本地分支、提交记录、暂存区面板。可通过
h/l
键或方向键切换。

Keybindings

快捷键

  • c
    : Commit
  • P
    : Push
  • p
    : Pull
  • s
    : Stage
  • c
    : 提交
  • P
    : 推送
  • p
    : 拉取
  • s
    : 暂存

Custom Commands

自定义命令

Define custom actions in
config.yml
(e.g. "Create PR").
可在
config.yml
中定义自定义操作(例如“创建PR”)。

Best Practices (2025)

2025年最佳实践

Do:
  • Interactive Rebase: Press
    i
    on a past commit to fix it up.
  • Filter: Press
    /
    to filter branches or files.
  • Bisect: Use the built-in bisect wizard to find bugs.
Don't:
  • Don't fear the CLI: Lazygit is a wrapper. Understanding underlying git concepts is still needed.
建议做法
  • 交互式变基:在历史提交记录上按
    i
    键来修正提交。
  • 筛选:按
    /
    键筛选分支或文件。
  • 二分查找:使用内置的二分查找向导定位bug。
不建议做法
  • 不要畏惧CLI:Lazygit只是Git的一个封装工具,仍需理解Git的底层概念。

References

参考链接