Tig is a tool to optimize the Git command line, making it more convenient and user-friendly. If you get used to it, it’s addictive.

basis

The installation

The easiest way to do this on Mac is to use Homebrew:

brew install tig
Copy the code

For other installation methods, see here

use

The following is recommended to be read by yourself in Repository

After the installation, Enter [tig] + [Enter] in the Repo folder to Enter the TIG mode. What is presented is all the local COMMIT records and the evolution of the branches.

[j] [k] can switch the selected line up and down, [Enter] can view the details of the current commit record in split screen, [L + q] can view the commit record in full screen.

[r] Enter refs View mode to view all branches, switch up and down using [J /k], and [Enter] to view branch evolution.

ใ€ s ใ€‘ Enter the status view and the git status command will display all Untracked and UnStaged files. Select Unstaged files and type [U] effect with Git Add, or select passively lit files and type [U] effect with Git reset to undo the ADD operation. [Enter] View Split screen View the modification records of the current file.

In status View mode, type [C] to enter vim editor, [I] to enter edit mode, enter commit information on the first line, [:x] exit and save. [m] Query commit records.

[C] Enter stash View mode and view the modification record in full screen, which can be used together with [S].

[t] Enter tree View mode, git directory will be displayed as a folder. [Enter] Goes to the subdirectory. [,] returns to the upper directory.

[m] Enter main View to view all commit records of the current branch, use [j/k] to switch up and down, and [Enter] to split screen to view commit details. Similarly, j/k moves up and down, space turns pages.

The main view can be thought of as the home page.

[/] Enter the keyword to search.

[R] Refresh the current page to exit the highlighted state of search.

[Q] Quit TIG.

[h] View shortcut keys help.

Tig can be scoped. If you want to focus only on changes to a folder, use tiG folder name.

Tig –after= “2018-01-01 –before=”2018-05-12” if you only want to show commit records for a certain period of time. You can use tig –after== may.10th ‘if you want to write without quotes.

In split screen mode, use Tab to switch between left and right screens, or hold down Shift to switch up and down on the left screen when the right screen is selected.

From the above introduction, TIG is more inclined to view.

Advanced article

The shortcut keys above are the default Settings, so we can customize them. The custom file is stored in the ~/. Tigrc directory. If this file is not available after the installation, create it yourself, copy the system configuration, and modify it.

For example, if you don’t like the folder color shown in [t], you can change blue to red.

color "tree "			blue	default
Copy the code

Tig supports the syntax of bind to implement custom shortcuts that map to specific Git commands. Bind status means that it will only take effect in status view mode ([s] key enter), P function is git push.

bind status P ! git pushCopy the code

! The delegate is executed immediately.

In the.tigrc file:

bindrefs C ? git checkout %(branch)Copy the code

In refs View mode, type the [C] checkout branch and ask for confirmation before executing.

Caution Restart the terminal after setting the mapping relationship. More functions please dig yourself ๐Ÿ™‚

recommended

If you are not familiar with how Git works, go through the following tutorial and you will have a deeper understanding of Git.

learngitbranching.js.org/

Manual ยท trig-text-mode interface for Git