发布时间:2026-06-18阅读(0)
值得推荐的酷酷的git终端界面工具lazygit
Git是一个强大和好用的工具,可以让一切都基于git来做,并可以think in git。
但是git又是一个相对不好入门的东西,因为git的一些和精华都是基于命令行的。虽然有层出不穷的git gui客户端,但是基本都是对git基本命令的包装,也没有哪一个是值得可取的。今天虫虫给大家介绍一个很酷的,相对比较直观和容易的git终端客户端lazygit。

一个用于git命令的简单终端UI,使用golang基于gocui库开发的。

Lazygit和所有基于golang开发的程序一样,建议优先使用编译的二进制文件安装和发布:
目前Lazygit最新版本为0.43.4,各个平台的二进制包和源码都可以通过其github仓库的发布页面下载。

注意下载包后使用checksums.txt提供的哈希值校对文件。
dnfredhat系的linux发型包可以通过Copr(Cool Other Package Repo)获取安装:
sudo dnf copr enable atim/lazygit -ysudo dnf install lazygit
Lazygit也支持使用homebrew包管理器安装:公式可以在Homebrew核心中找到,
brew install jesseduffield/lazygit/lazygit
或者:
brew install lazygit
可以从github构建的最新版本:
sudo port install lazygit
windows用户也可以通过scoop安装 lazygit,但需要先配置extras:
scoop bucket add extrasscoop install lazygitt
本地机器上有golang环境的,可以直接获取源码安装:
git clone github/jesseduffield/lazygit.gitcd lazygitgo install
可以自己修改然后编译或者运行
go run main.go
Lazygit的使用非常简单,只需cd到git仓库目录,然后:
Lazygit

Lazygit使用完全依赖快捷键(支持自定义),而且快捷键也有点复杂,可以用x键,点出菜单使用:

详细键对应和自定义快捷键见官方文档。注意界面最下边有蓝色的提示信息:
1-5: jump to panel, H/L: scroll left/right, esc: cancel, pgup/pgdown: scroll, q: quit, x: menu, ◄ ► ▲ ▼: navigate
使用案例解决合并冲突

Lazygit完全支持个性化定制,支持定义快捷键、定义配色、自定义显示git命令内容等。其配置在不同平台是不同目录通过config.yml配置文件。
Windows:%APPDATA%\lazygit\config.ymlLinux:~/.config/lazygit/config.ymlMacos:~/Library/Application Support/lazygit/config.yml
默认配置项为/jesseduffield/lazygit/blob/master/docs/Config.md,可以自己基于默认配置做调整:
平台默认项目OS部分配置,文件打开Windows下:
openCommand: start "" {{filename}}
Linux:
openCommand: xdg-open {{Filename}} >/dev/null
OSX:
openCommand: open {{filename}}
os:editCommand: vim
还可以支持:
$(git config core.editor)$GIT_EDITOR$VISUAL$EDITOR$(which vi)
可以配置,显示行号:
editCommand: vimeditCommandTemplate: {{editor}} {{line}} {{filename}}
使用选项--use-config-file指定配置文件位置(覆盖默认的位置)
lazygit --use-config-file=~/.base_lg_conf,~/.light_theme_lg_conf
配置文件中的设置
LG_CONFIG_FILE="~/.base_lg_conf,~/.light_theme_lg_conf" lazygit
支持red等颜色名称,也支持rgb值比如#ff00ff,支持格式样式:
default,bold,underline,reverse # useful for high-contrast
一些样式范例:
gui:theme:lightTheme: trueactiveBorderColor:- black- boldinactiveBorderColor:- blackselectedLineBgColor:- default
或
gui: theme: activeBorderColor: - white - bold inactiveBorderColor:- whiteselectedLineBgColor:- reverse- blue
强调选中显示:
gui:theme:selectedLineBgColor:- reverseselectedRangeBgColor:- reverse

一个自定义快捷键的范例:
keybinding:universal:prevItem-alt: unextItem-alt: eprevBlock-alt: nnextBlock-alt: inextMatch: =prevMatch: -new: kedit: oopenFile: OscrollUpMain-alt1: UscrollDownMain-alt1: EscrollUpMain-alt2: <c-u>scrollDownMain-alt2: <c-e>undo: lredo: <c-r>diffingMenu: MfilteringMenu: <c-f>files:ignoreFile: Icommits:moveDownCommit: <c-e>moveUpCommit: <c-u>branches:viewGitFlowOptions: IsetUpstream: U
一些git渲染的配置在配置文件的git部分,比如git log的格式配置:
git:branchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium --oneline {{branchName}} --"
配置效果:

本文给大家推荐了一个很的git客户端工具lazygit,使用方便,界面绚丽,适合小白们和喜欢尝鲜的同学使用。大家如果手头有类似酷酷工具,可以回复推荐给大家。
Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图