Saltar a contenido
__HTML_TAG_130_ All tig Commands

Tig (Text-mode Interface for Git) Cheatsheet

Instalación

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

Verificar la instalación: tig --version

Comandos básicos

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
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

Cayos de búsqueda y filtro

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

Comandos Avanzados

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

Interactive Operations (Inside Tig)

__TABLE_141_

Configuración

Tig lee la configuración de estos lugares (en orden prioritario):

  1. $XDG_CONFIG_HOME/tig/config (típicamente ~/.config/tig/config)
  2. ~/.tigrc_
  3. $GIT_DIR/tigrc (repositorio específico)
  4. /etc/tigrc_ (en todo el sistema)

Crear archivo de configuración

# 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

Ver Configuraciones

# 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 = ~

Configuración de Diff

# 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 Cadenas clave

# 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)

Mostrar opciones

# 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

Common Use Cases

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 Introduced

# 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: Exploring Project History

# 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

Buenas prácticas

  • Aprenda los atajos del teclado: Tig está diseñado para la navegación del teclado. Memorizar j/k para el movimiento, Enter_ para perforar hacia abajo, y q para volver a navegar eficientemente.

  • Use comandos de vista específicos: Diferentes vistas tienen diferentes operaciones. Presione h_ en cualquier punto de vista para ver los enlaces clave disponibles para ese contexto.

  • Personalizar su configuración: Cree un archivo ~/.config/tig/config para personalizar los colores, las encuadernaciones y ver la configuración para que coincida con su flujo de trabajo y sus preferencias.

  • Combine con los comandos de Git. Utilice el tig para visualización y comandos Git para operaciones. Complementos de tig Más bien que reemplazarlo.

  • Use filtros para grandes repositorios: En depósitos con miles de commits, use --author, --since, --grep_, o filtros de archivo para resultados estrechos.

Aprobar la vista del estado: Use tig status_ como alternativa interactiva a git add -p para el control de estadificación granular.

  • Explore con Tab: Use Tab para recorrer puntos de vista relacionados y ver diferentes perspectivas sobre los mismos datos (commit → diff → árbol).

  • Confíe el repositorio específico: Crear .git/tigrc en repositorios que necesitan ajustes especiales sin afectar su configuración global.

Troubleshooting

__TABLE_142_

Quick Reference Card

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