_
_
Tig (Text-Modus-Schnittstelle für Git) Cheatsheet¶
• Installation
| Platform | Command |
|---|---|
| Ubuntu/Debian | INLINE_CODE_12 |
| Fedora/RHEL | INLINE_CODE_13 |
| Arch Linux | INLINE_CODE_14 |
| macOS (Homebrew) | INLINE_CODE_15 |
| macOS (MacPorts) | INLINE_CODE_16 |
| Windows (Git Bash) | Included with Git for Windows |
| Windows (WSL) | INLINE_CODE_17 |
| Windows (Scoop) | INLINE_CODE_18 |
| From Source | INLINE_CODE_19 |
| _ | |
Verify Installation: tig --version |
oder Grundlegende Befehle
| Command | Description |
|---|---|
| INLINE_CODE_21 | Open main view showing commit history in current repository |
| INLINE_CODE_22 | Show working directory status (like INLINE_CODE_23) |
| INLINE_CODE_24 | Show line-by-line authorship for a file |
| INLINE_CODE_25 | Show commit history for a specific file |
| INLINE_CODE_26 | Display details of a specific commit |
| INLINE_CODE_27 | Show all branches and tags |
| INLINE_CODE_28 | Display all stashed changes |
| INLINE_CODE_29 | Show commit log view |
| INLINE_CODE_30 | Show unstaged changes in working directory |
| INLINE_CODE_31 | Search for pattern in repository |
| INLINE_CODE_32 | Show commits from a specific branch |
| INLINE_CODE_33 | Show commits from all branches |
| INLINE_CODE_34 | Display help information |
| INLINE_CODE_35 | Show tig version information |
| _ | |
| Navigationstasten (Inside Tig) |
| Key | Description |
|---|---|
| INLINE_CODE_36 / INLINE_CODE_37 | Move down one line |
| INLINE_CODE_38 / INLINE_CODE_39 | Move up one line |
| INLINE_CODE_40 / INLINE_CODE_41 | Scroll left |
| INLINE_CODE_42 / INLINE_CODE_43 | Scroll right |
| INLINE_CODE_44 / INLINE_CODE_45 | Page up |
| INLINE_CODE_46 / INLINE_CODE_47 | Page down |
| INLINE_CODE_48 | Jump to first line |
| INLINE_CODE_49 | Jump to last line |
| INLINE_CODE_50 | Open/select item (context-dependent) |
| INLINE_CODE_51 | Switch to next view |
| INLINE_CODE_52 | Close current view |
| INLINE_CODE_53 | Close all views and quit |
| INLINE_CODE_54 | Reload/refresh current view |
| INLINE_CODE_55 | Maximize current view |
| INLINE_CODE_56 | Show help and key bindings |
| _ | |
| Suche und Filter Schlüssel |
| Key | Description |
|---|---|
| INLINE_CODE_57 | Search forward |
| INLINE_CODE_58 | Search backward |
| INLINE_CODE_59 | Find next match |
| INLINE_CODE_60 | Find previous match |
| INLINE_CODE_61 | Jump to previous diff chunk |
| INLINE_CODE_62 | Jump to next diff chunk |
| INLINE_CODE_63 | Jump to previous file in diff |
| INLINE_CODE_64 | Jump to next file in diff |
| _ | |
| Erweiterte Befehle |
| Command | Description |
|---|---|
| INLINE_CODE_65 | Filter commits by specific author |
| INLINE_CODE_66 | Show commits from a relative date |
| INLINE_CODE_67 | Show commits within date range |
| INLINE_CODE_68 | Show commits with pattern in message |
| INLINE_CODE_69 | Show only merge commits |
| INLINE_CODE_70 | Exclude merge commits |
| INLINE_CODE_71 | Show commits in feature not in main |
| INLINE_CODE_72 | Show commits that differ between branches |
| INLINE_CODE_73 | Track file history through renames |
| INLINE_CODE_74 | Pickaxe search: commits changing occurrences |
| INLINE_CODE_75 | Show commits where diff matches regex |
| INLINE_CODE_76 | Limit to last 100 commits |
| INLINE_CODE_77 | Show commits affecting Python files only |
| INLINE_CODE_78 | Browse Git reflog entries |
| INLINE_CODE_79 | Display file content at specific commit |
| INLINE_CODE_80 | Open blame view at specific line number |
| _ | |
| Interaktive Operationen (Inside Tig) |
| Key | View | Description |
|---|---|---|
| INLINE_CODE_81 | status | Stage/unstage file or chunk |
| INLINE_CODE_82 | status | Stage/unstage single line |
| INLINE_CODE_83 | status | Revert file or chunk |
| INLINE_CODE_84 | status | Commit staged changes |
| INLINE_CODE_85 | main/log | Cherry-pick commit |
| INLINE_CODE_86 | main/log | Edit commit message (if HEAD) |
| INLINE_CODE_87 | main/log | Revert commit |
| INLINE_CODE_88 | main/log | Move to commit (checkout) |
| INLINE_CODE_89 | refs | Create new branch |
| INLINE_CODE_90 | refs | Delete branch |
| INLINE_CODE_91 | refs | Merge branch |
| INLINE_CODE_92 | any | Execute external command |
| INLINE_CODE_93 | any | Execute git command (e.g., INLINE_CODE_94) |
| _ | ||
| Konfiguration |
Tig liest Konfiguration von diesen Orten (in Prioritätsreihenfolge):
ANHANG $XDG_CONFIG_HOME/tig/config (typisch ~/.config/tig/config_)
2. ~/.tigrc
3. $GIT_DIR/tigrc (repository-spezifisch)
4. /etc/tigrc (systemweit)
Konfigurationsdatei erstellen¶
# Create user config directory and file
mkdir -p ~/.config/tig
touch ~/.config/tig/config
# Or use traditional location
touch ~/.tigrc
Color Customization¶
# Customize interface colors
color cursor white blue bold
color title-focus white blue bold
color title-blur white black bold
# Diff colors
color diff-header yellow default
color diff-chunk magenta default
color diff-add green default
color diff-del red default
# Status colors
color stat-staged green default
color stat-unstaged red default
color stat-untracked yellow default
Einstellungen anzeigen¶
# Configure main view columns
set main-view = id:yes date:default author:full commit-title:yes,graph:yes,refs:yes
# Set commit ID width
set id-width = 10
# Enable line numbers in blame view
set blame-view = date:default author:full id:yes,color line-number:yes,interval=1 text
# Line number display interval
set line-number-interval = 5
# Horizontal scrolling percentage
set horizontal-scroll = 33%
# Tab size for display
set tab-size = 4
# Truncation indicator
set truncation-delimiter = ~
Diff Konfiguration¶
# Number of context lines in diffs
set diff-context = 3
# Ignore whitespace (options: no, all, some, at-eol)
set ignore-space = some
# Use patience diff algorithm
set diff-options = --patience
# Show untracked files in status view
set status-show-untracked-files = yes
Custom Schlüsselbindungen¶
# Bind 'C' in main view to cherry-pick
bind main C !git cherry-pick %(commit)
# Bind 'P' in status view to push
bind status P !git push
# Bind 'F' to fetch in main view
bind main F !git fetch
# Bind 'S' to create stash
bind status S !git stash save "%(prompt Enter stash message: )"
# Bind 'A' to amend commit
bind status A !git commit --amend
# Open commit in browser (GitHub)
bind main B !@hub browse -- commit/%(commit)
Optionen anzeigen¶
# Wrap long lines
set wrap-lines = yes
# Show changes in status view
set status-show-untracked-dirs = yes
# Refresh interval (seconds)
set refresh-mode = auto
set refresh-interval = 1
# Mouse support
set mouse = yes
# Editor for commit messages
set editor-line-number = yes
Häufige Anwendungsfälle
Use Case 1: Code Review Workflow¶
# Open repository
tig
# Navigate to commit (use j/k)
# Press Enter to see full diff
# Press Tab to switch between views
# Press q to go back
# Review specific branch
tig feature-branch
# Compare branches
tig main..feature-branch
Use Case 2: Finding When a Bug was Introducing¶
# Search for specific code change
tig -S"problematic_function"
# Or search commit messages
tig --grep="bug\|fix" -i
# View blame for specific file
tig blame src/buggy-file.js
# Navigate to suspicious line
# Press Enter to see the commit
# Press Tab to see full commit details
Use Case 3: Interactive Staging and Committing¶
# Open status view
tig status
# Navigate to files (j/k)
# Press 'u' to stage/unstage files
# Press '1' to stage individual lines
# Press 'C' to commit when ready
# Write commit message and save
Use Case 4: Projektgeschichte erkunden¶
# View all commits with graph
tig --all
# Filter by author and date
tig --author="John Doe" --since="1 month ago"
# View commits affecting specific files
tig -- src/core/*.py
# Follow file through renames
tig --follow -- src/renamed-file.js
Use Case 5: Branch Management¶
# View all branches and tags
tig refs
# Navigate to branch
# Press 'C' to create new branch
# Press 'd' to delete branch
# Press 'm' to merge branch
# Press Enter to view branch commits
oder Best Practices
-
**Learn Tastaturabkürzungen*: Tig ist für die Tastaturnavigation konzipiert. Memorize
j/kfür Bewegung,Enterzum Bohren nach unten, undqzum effizienten Surfen zurückgehen. -
**Benutze blickspezifische Befehle*: Verschiedene Ansichten haben unterschiedliche Operationen. Drücken Sie
hin jeder Hinsicht, um verfügbare Schlüsselbindungen für diesen Kontext zu sehen. -
**Kundenspezifische Konfiguration*: Erstellen Sie eine
~/.config/tig/config-Datei, um Farben, Bindungen und Einstellungen zu Ihrem Workflow und Präferenzen anzupassen. -
** Kombinieren Sie mit Git Befehlen*: Verwenden Sie tig für Visualisierung und Git Befehle für Operationen. Tig ergänzt Git statt es zu ersetzen.
-
** Filter für große Repositories*: In Repositories mit Tausenden von Commits verwenden Sie
--author,--since,--grepoder Dateifilter zu engen Ergebnissen. -
**Leverage die Statusansicht*: Verwenden Sie
tig statusals interaktive Alternative zugit add -pzur körnigen Staging Control. -
**Explore mit Tab*: Verwenden Sie
Tab, um durch verwandte Ansichten zu zyklieren und verschiedene Perspektiven auf die gleichen Daten zu sehen (bekommen → diff → tree). -
** Repository-spezifische Configs einrichten*: Erstellen
.git/tigrcin Repositories, die spezielle Einstellungen benötigen, ohne Ihre globale Konfiguration zu beeinflussen.
Fehlerbehebung
| Issue | Solution |
|---|---|
| Tig not found after installation | Ensure tig is in your PATH: INLINE_CODE_112. Restart terminal or run INLINE_CODE_113 |
| Colors not displaying correctly | Check terminal supports 256 colors. Set INLINE_CODE_114 or configure colors in INLINE_CODE_115 |
| Slow performance in large repos | Use filters to limit commits: INLINE_CODE_116 or INLINE_CODE_117. Consider INLINE_CODE_118 |
| UTF-8 characters display incorrectly | Set locale: INLINE_CODE_119 and INLINE_CODE_120 in shell config |
| Mouse not working | Enable in config: INLINE_CODE_121. Ensure terminal supports mouse events |
| Can't edit commits or stage files | Ensure you have write permissions and are in a valid Git repository. Check INLINE_CODE_122 works |
| Custom key bindings not working | Verify syntax in config file. Check for conflicts with default bindings. Reload with INLINE_CODE_123 |
| Tig crashes on startup | Check Git repository is valid: INLINE_CODE_124. Update tig to latest version. Remove custom config temporarily |
| Diff view shows binary files | Add to INLINE_CODE_125: INLINE_CODE_126. Or set INLINE_CODE_127 |
| Line numbers not showing | Enable in config: INLINE_CODE_128 and ensure view supports line numbers |
| _ | |
| Kurze Referenzkarte |
LAUNCHING TIG NAVIGATION OPERATIONS
tig j/k ↓/↑ Move u Stage/unstage
tig status h/l ←/→ Scroll C Commit/cherry-pick
tig blame <file> PgUp/PgDn Page ! Revert/execute
tig <branch> Enter Select e Edit
tig --all Tab Next view @ Checkout
q/Q Quit R Refresh
SEARCH VIEWS FILTERS
/ Search forward tig Main --author="Name"
? Search backward tig status Status --since="date"
n Next match tig refs Branches --grep="pattern"
N Previous match tig blame Blame --no-merges
[ Prev chunk tig stash Stash -- '*.ext'
] Next chunk tig diff Diff