安裝 tig
# archlinux
$ pacman -S tig
# Mac
$ brew install tig
用 tig 看 Git log (tig --all)
使用 tig 看 git log
$ tig --all
tig view
tig 提供 各種不同功能的 view
h 顯示 help view
m 顯示 main view
s, S 顯示 status view
l 顯示 log view
t 顯示 tree view
c 顯示 stage view
d 顯示 diff view
y 顯示 stash view
b 顯示 blame view
r 顯示 refs view
f 顯示 blob view
g 顯示 grep view
p 顯示 pager view
R, F5 重新載入 view
O 最大化當前 view
<Tab> view-next
q 關掉當前 view Q 關掉所有的 view 並離開
< 前一個 view 狀態
C-u 往上捲 C-d 往下捲
j, k 向下 下上移動
tig History view
$ tig --all
# 進入 History view
h (進入 help view)
j, k (向下 下上移動)
/ (搜尋 summary author)
t (打開 tree view)
對選定的 commit 按 enter
會顯示 split diff view
shift-S (進入 status view)
What's going on in remote branches
$ tig origin/develop
tig Status view
$ tig status
- u
- stage or unstage file
- !
- revert all uncommitted changes to that file
Shift-C (commit)
在檔案上按 Enter
j, k 上下移動
@ (navigate chunk by chunk)
u (stage the current diff chunk)
@@
1 (數字1) (Changed but not updated stage a single line)
1 (數字1) (Changes to be committed unstage a single line)
tig stash
$ tig stash
P (git stash pop)
! (git stash drop)
tig Blame view
$ tig blame <flie>
# Just select a line and press Enter,
# and it will show you the last commit that touched that line.
t tree view
S status view
@
客製化 tig
透過 ~/.tigrc 可以客製化 tig 的行為
預設的設定 在 github 上的 source code 可以看到
tigrc example
# Views {{{
set blame-view = date:default author:full file-name:auto id:yes,color line-number:no,interval=5 text
set grep-view = file-name:no line-number:yes,interval=1 text
set main-view = line-number:no,interval=5 id:yes date:default author:full commit-title:yes,graph,refs,overflow=no
set refs-view = date:default author:full ref commit-title
set stash-view = line-number:no,interval=5 id:no date:default author:full commit-title
set status-view = line-number:no,interval=5 status:short file-name
set tree-view = line-number:no,interval=5 mode author:full file-size date:default id:no file-name
# }}}