值得推荐的酷酷的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提供的哈希值校对文件。
dnf
redhat系的linux发型包可以通过Copr(Cool Other Package Repo)获取安装:
sudo dnf copr enable atim/lazygit -y
sudo dnf install lazygit
Homebrew
Lazygit也支持使用homebrew包管理器安装:公式可以在Homebrew核心中找到,
brew install jesseduffield/lazygit/lazygit
或者:
brew install lazygit
Macport
可以从github构建的最新版本:
sudo port install lazygit
scoop
windows用户也可以通过scoop安装 lazygit,但需要先配置extras:
scoop bucket add extras
scoop install lazygitt
源码安装
本地机器上有golang环境的,可以直接获取源码安装:
git clone github/jesseduffield/lazygit.git
cd lazygit
go 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
使用案例
解决合并冲突
交互式rebase
个性化配置
Lazygit完全支持个性化定制,支持定义快捷键、定义配色、自定义显示git命令内容等。其配置在不同平台是不同目录通过config.yml配置文件。
Windows:%APPDATA%\lazygit\config.yml
Linux:~/.config/lazygit/config.yml
Macos:~/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: 'vim'
editCommandTemplate: '{{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: true
activeBorderColor:
- black
- bold
inactiveBorderColor:
- black
selectedLineBgColor:
- default
或
gui:
theme:
activeBorderColor:
- white
- bold
inactiveBorderColor:
- white
selectedLineBgColor:
- reverse
- blue
强调选中显示:
gui:
theme:
selectedLineBgColor:
- reverse
selectedRangeBgColor:
- reverse
自定义快捷键
一个自定义快捷键的范例:
keybinding:
universal:
prevItem-alt: 'u'
nextItem-alt: 'e'
prevBlock-alt: 'n'
nextBlock-alt: 'i'
nextMatch: '='
prevMatch: '-'
new: 'k'
edit: 'o'
openFile: 'O'
scrollUpMain-alt1: 'U'
scrollDownMain-alt1: 'E'
scrollUpMain-alt2: '<c-u>'
scrollDownMain-alt2: '<c-e>'
undo: 'l'
redo: '<c-r>'
diffingMenu: 'M'
filteringMenu: '<c-f>'
files:
ignoreFile: 'I'
commits:
moveDownCommit: '<c-e>'
moveUpCommit: '<c-u>'
branches:
viewGitFlowOptions: 'I'
setUpstream: 'U'
自定义git log格式
一些git渲染的配置在配置文件的git部分,比如git log的格式配置:
git:
branchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium --oneline {{branchName}} --"
配置效果:
总结
本文给大家推荐了一个很的git客户端工具lazygit,使用方便,界面绚丽,适合小白们和喜欢尝鲜的同学使用。大家如果手头有类似酷酷工具,可以回复推荐给大家。
本文暂时没有评论,来添加一个吧(●'◡'●)