GitUI: 用 Rust 编写的 Git 的快速命令行客户端
Git
![](/data/attachment/album/202110/26/111605achvngqr6ix6vv0p.jpg)


[基本的 Git 命令](https://itsfoss.com/basic-git-commands-cheat-sheet/) 对于通常的克隆、添加、提交推送已经足够好了。


但如果你在一个有多个贡献者的大型项目上工作，你可能需要将事情可视化。GUI 工具可以让你更好地了解 `diff`、`stash` 和 `blame` 的情况。


但是，如果你常用终端，又想要 Git 的舒适性，我为你准备了一个好工具。


它叫 GitUI，它提供了类似于 Git GUI 的用户体验和舒适度，但就在你的终端中。它是可移植的、快速的、自由而开源的。


### GitUI：一个基于终端的 Git 工具


[GitUI](https://github.com/Extrawurst/gitui) 并不是第一个用于 Linux 终端的 Git 客户端。那么，是什么让 GitUI 与其他类似项目如 [lazygit](https://github.com/jesseduffield/lazygit) 或 [tig](https://jonas.github.io/tig/) 不同？


GitUI 的开发者在项目的 README 文件中分享了一些基准数据。




| 名称 | 时间 | 内存（GB） | 二进制（MB） | 冻结 | 崩溃 |
| --- | --- | --- | --- | --- | --- |
| gitui | 24 s | 0.17 | 1.4 | 否 | 否 |
| lazygit | 57 s | 2.6 | 16 | 是 | 有时 |
| tig | 4 m 20 s | 1.3 | 0.6 | 有时 | 否 |


*GitUI、LazyGit 和 Tig 之间的比较。*


这种优化大部分来自于 Rust 语言的使用。


**注意：该程序处于早期开发阶段，还没有为生产做好准备。**


### 在 Linux 上安装 GitUI


不用说，你应该已经 [在你的系统上安装了 Git](https://itsfoss.com/install-git-ubuntu/)。


要使用 GitUI，首先需要 [为你的 Linux 发行版安装 Rust 支持](https://itsfoss.com/install-rust-cargo-ubuntu-linux/)。


在终端中，使用以下命令：



```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

```

![Installing Rust on Linux](/data/attachment/album/202110/26/111616fygydi5uwwiyyrnr.png)


当你被要求选择时，请选择选项 1。当脚本完成安装后，用这个命令正确设置配置：



```
source $HOME/.cargo/env

```

现在你已经安装了 Rust 和它的包管理器 Cargo，使用 Cargo 命令来安装 GitUI：



```
cargo install gitui

```

然后你就可以使用 GitUI了，只需在终端输入 `gitui` 就可以运行了。我做了一些示例文件来测试 Git 和 GitUI。


![Starting gitui on terminal](/data/attachment/album/202110/26/111617b8l00of2zay9egoy.png)


值得一提的是，这个界面有一个快速而直观的纯键盘控制。一切都很简单，只需输入正确的字母即可将文件暂存、提交、分支或推送到 git 仓库中。


真正让我兴奋的是，你不仅可以做之前的四个动作，还可以**编辑**每个文件，**拉取**它，**追溯** 它，在其中**导航**等等，这一切都无需退出界面。 很棒，不是吗？


![More functions inside the interface](/data/attachment/album/202110/26/111617ioe13ez64fsv764s.png)


祝贺你! 现在你知道了如何安装 GitUI 以及它在你的终端中的样子。


如果你喜欢这个项目，请在 [GitHub](https://github.com/Extrawurst/gitui) 上点赞它的仓库。如果你使用其他工具来管理 Git，请在评论区提出你的建议。




---


via: <https://itsfoss.com/gitui/>


作者：[Marco Carmona](https://itsfoss.com/author/marco/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
The [basic Git commands](https://itsfoss.com/basic-git-commands-cheat-sheet/) are good enough for the usual clone, add, commit push.

But if you are working on a large project with multiple contributors, you may need to visualize things. A GUI tool gives a better view on the diff, stash and blame.

But then, if you are a terminal dweller, who wants the comfort of GUI with Git, I have got a good tool for you.

It is called GitUI and it provides user experience and comfort similar to a git GUI but right in your terminal. It is portable, fast, free and open source.

## GitUI: A terminal based tool for Git

[GitUI](https://github.com/Extrawurst/gitui) is not the first Git client for Linux terminal. So, what makes GitUI different than other similar projects like [lazygit](https://github.com/jesseduffield/lazygit) or [tig](https://jonas.github.io/tig/)?

GitUI developer has shared some benchmark in the README file of the project.

Time | Memory (GB) | Binary (MB) | Freezes | Crashes | |

gitui | 24 s | 0.17 | 1.4 | No | No |

lazygit | 57 s | 2.6 | 16 | Yes | Sometimes |

tig | 4 m 20 s | 1.3 | 0.6 | Sometimes | No |


Most of this optimization comes from the use of Rust programming language.

*Note: This program is in early stages of development and is not production ready yet.*

## Installing GitUI on Linux

Needless to say, you should have [Git installed on your system](https://itsfoss.com/install-git-ubuntu/) already.

To use GitUI, you need to [install Rust support for your Linux distribution](https://itsfoss.com/install-rust-cargo-ubuntu-linux/) first.

In a terminal, use the following command:

`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`


![Installing rust on Linux](https://itsfoss.com/content/images/wordpress/2021/10/Installing-Rust-step-1-800x471.png)

Go with option 1 when you are asked for a choice. When script finishes installation, set the configuration right with this command:

`source $HOME/.cargo/env`


Now that you have Rust and its package manager Cargo installed, use the Cargo command to install GitUI:

`cargo install gitui`


And you’re ready to use GitUI, for that just type `gitui`

in the terminal to run it. I made some sample files to play with Git and GitUI.

![starting gitui on terminal](https://itsfoss.com/content/images/wordpress/2021/10/Starting-GitUI-on-terminal-800x471.png)

It’s important to mention that the interface has a fast and intuitive keyboard-only control. Everything is as easy as type the correct letter to stage, commit, branch, or push your files into your git repository.

Something that really gets me excited was that you can not only do the four actions before, but you can also **edit** each file, **pull** it, **blame** it, **navigate** inside it, and more things; everything without existing from the interface. Awesome, isn’t it?

![more functions inside the interface](https://itsfoss.com/content/images/wordpress/2021/10/More-functions-inside-the-interface-800x471.png)

Felicitations! Now you know how to install GitUI and how it looks like in your terminal.

If you like the project, start its repository on [GitHub](https://github.com/Extrawurst/gitui). If you use some other tool to manage Git, please suggest your favorite in the comment section.