OSDN Git Service

Regular updates
[twpd/master.git] / tig.md
1 ---
2 title: Tig
3 category: Git
4 layout: 2017/sheet
5 updated: 2018-11-16
6 weight: -3
7 ---
8
9 ### Installing
10
11 ```bash
12 # MacOS + Homebrew
13 $ brew install tig --HEAD
14 ```
15
16 ```bash
17 # Ubuntu
18 $ sudo apt install tig
19 ```
20
21 ### Invocation
22
23 | Command             | Description                                  |
24 | ------------------- | -------------------------------------------- |
25 | `tig`               |                                              |
26 | ---                 | ---                                          |
27 | `tig status`        | Status                                       |
28 | `tig blame FILE`    | Blame                                        |
29 | ---                 | ---                                          |
30 | `tig master`        | Show a branch                                |
31 | `tig test..master`  | Show difference between two branches         |
32 | `tig FILE`          | Show history of file                         |
33 | `tig v0.0.3:README` | Show contents of file in a specific revision |
34 | `tig -C /repo/path` | Run in dir `/repo/path` (like `git -C`)      |
35
36 You can substitute `git log` → `tig`.
37
38 ## Shortcut keys
39 {: .-three-column}
40
41 ### Switching views
42
43 | `m` | Main view |
44 | `s` | Status |
45 | `t` | Tree (files) |
46 | `y` | Stash view |
47 | `g` | Grep |
48 | `h` | Help |
49 {: .-shortcuts}
50
51 ### All views
52
53 | Shortcut | Description             |
54 | ---      | ---                     |
55 | `j`  `k` | Up/down                 |
56 | `J`  `K` | Next/previous           |
57 | ---      | ---                     |
58 | `<`      | Back                    |
59 | `R`      | Refresh                 |
60 | `q`      | Close                   |
61 | `Q`      | Close all               |
62 | ---      | ---                     |
63 | `^N`     | Next on parent view     |
64 | `^P`     | Previous on parent view |
65 {: .-shortcuts}
66
67 ### `m` - Main view
68
69 | `D` | Toggle date display modes   |
70 | `A` | Toggle author display modes |
71 | `X` | Toggle commit sha           |
72 | `C` | Cherry pick a commit        |
73 {: .-shortcuts}
74
75 ### `s` - Status view
76
77 | `u`     | Stage/unstage file or chunk        |
78 | `!`     | Revert file or chunk               |
79 | `C`     | Commit                             |
80 | `M`     | Merge                              |
81 | `1`     | Stage line                         |
82 | `[` `]` | Increase/decrease the diff context |
83 {: .-shortcuts}
84
85 ### `h` - Branch view
86
87 | `i` | Change sort header |
88 {: .-shortcuts}
89
90 ### `h` - Blame view
91
92 | `,` | Parent commit |
93 {: .-shortcuts}