Docu review done: Thu 29 Jun 2023 12:34:21 CEST
Table of Content
General
Tig is an ncurses-based text-mode interface for git. It functions mainly as a Git repository browser, but can also assist in staging changes for commit at chunk level and act as a pager for output from various Git commands.
Installation
Debian
$ apt install tig
Configuration
the configuration of
tig
has its own man pagetigrc
which contains samples of configuration snippes and so on
There are several places to store the coniguration for tig
:
$XDG_CONFIG_HOME/tig/config
~/.config/tig/config
~/.tigrc
/etc/tigrc
You can also place your tig
configuration inside of git configs:
$GIT_DIR/config
~/.gitconfig
/etc/gitconfig
If you have tig
complied on your own and added the readline
support, then you get also a command and search history file.
If you have it installed via apt you will get tig
with readline
support enabled.
Locations:
$XDG_DATA_HOME/tig/history
~/.local/share/tig/history
~/.tig_history
The location of the history file is determined in the following way. If
$XDG_DATA_HOME
is set and$XDG_DATA_HOME/tig/
exists, store history to$XDG_DATA_HOME/tig/history
. If$XDG_DATA_HOME
is empty or undefined, store history to~/.local/share/tig/history
, if the directory~/.local/share/tig/
exists. Fall back to~/.tig_history
if~/.local/share/tig/
does not exist.
If you add your tig
configuration into your git config file, it follows the same style guied as the git configuration:
[tig]
commit-order = topo
line-graphics = yes
tab-size = 4
main-view-date-local = true
You can also add your own keybindings inside of the config file:
[tig "bind"]
generic = P !git push
generic = p !git plr
generic = S :source ~/.gitconfig
generic = 9 !echo -n "%(commit)" | xclip -selection c
status = + !git commit --amend
Commands
If you just run tig
without any parameter, the ncurses gui will open and start do display you the git log.
But of course it has some very usefull parmeters, to make your live easier.
Command | Description |
---|---|
blame | Show given file annotated by commits. Takes zero or more git-blame options. Optionally limited from given revision. |
status | Startup in status view, close to git-status |
reflog | Start up in reflog view |
refs | Start up in refs view. All refs are displayed unless limited by using one of the --branches , --remotes , or --tags parameters. |
stash | Start up in stash view |
grep [pattern] | Open the grep view. Supports the same options as git-grep . |
Samples
These samples can be also looked at
man tig
Command | Description |
---|---|
tig test master | Display commits from one or more branches |
tig --all | Pretend as if all the refs in refs/ are listed on the command line |
tig test..master | Display differences between two branches |
tig --submodule | Display changes for sub-module versions |
tig -- README | Display changes for a single file |
tig README | Display changes for a single file |
tig show tig-0.8:README | Display contents of the README file in a specific revision |
tig --after="2004-01-01" --before="2006-05-16" -- README | Display revisions between two dates for a specific file |
tig blame -C README | Blame file with copy detection enabled |
tig --word-diff=plain | Use word diff in the diff view |
Keybindings
To interact with tig
it offers you a bunch of keybindings.
To create own keybindings, have a look at the config section
These are just a small list what it can do, but which I use on a regulare base:
Sekction | Key | Description |
---|---|---|
General | ||
│ | h | displays the help (also shows your custom bindings) |
│ | ENTER | enter and open selected line |
│ | e | opens file (on selected line) in editor |
│ | q | closes current view/section/…, closes tig if you are back to the started view |
└ | Q | closes tig always |
Views | ||
│ | d | opens diff view |
│ | j /k | move down/up |
│ | g | allows you to perform git-grep and displays result |
└ | X | toggles column of short commit ids in main view |
Search | ||
│ | / | let you search in the current view (like it odes in vim ) |
│ | ? | let you search-back in the current view (like it odes in vim ) |
│ | n | find next |
└ | N | find previous |
If you have opened a view at the same time with a diff (in split mode), the
j
/k
will move your cursor in the diff section. But you can still navigate in the original view as well, just use your arrow keys (up and down). The diff view will stay and update the content to the selected line.e.g. you are in the main view, presse
ENTER
to open the diff for the last commit and then pressarrow down
, now you will get the diff displayed for the second last commit.