Por Anónimo (no verificado) , 29 Abril 2026

Sinopsis

git update-index [--add] [--remove] [--refresh] [--assume-unchanged] <file>...

Descripción

El comando git update-index es plumbing de bajo nivel para manipular el index. Hace lo que git add hace pero con muchas más opciones: cambiar bits ejecutables, marcar archivos como assume-unchanged, refrescar info stat.

Raramente necesario para usuarios; útil para scripts y para situaciones específicas como configurar --skip-worktree en archivos de configuración locales.

En el uso diario, este comando se integra estrechamente con alias de shell, plugins de editor e integración continua. Los usuarios avanzados a menudo añaden alias que combinan los flags que siempre pasan. El formato de salida puede personalizarse vía configuración de Git. Cuando algo sale mal, ejecuta el comando con GIT_TRACE=1 para revelar las llamadas plumbing subyacentes.

Entender cómo este comando interactúa con el resto del modelo de datos de Git rinde dividendos. Cada comando opera sobre algún subconjunto de las piezas (objetos, index, refs, árbol de trabajo), y saber cuáles toca ayuda a predecir resultados y a recuperarse de errores.

Cuándo usar

Most users never need this directly. Reach for it when you want behaviors not exposed by porcelain: marking a file as assume-unchanged to avoid noisy status output for a config file you intentionally modify locally; or skip-worktree for sparse-checkout-like scenarios.

Opciones comunes

OpciónDescripción
--addAdd files not yet in the index.
--removeRemove files from the index.
--refreshRefresh stat info without changing content.
--assume-unchangedTell Git not to check this file for changes.
--no-assume-unchangedReverse the flag.
--skip-worktreeMake Git ignore working-tree changes.
--chmod=(+|-)xChange executable bit.
--cacheinfo <mode> <sha> <path>Manually splice an entry into the index.

Ejemplos

git update-index --assume-unchanged config/local.yml
# Stop tracking local edits to a config file

git update-index --no-assume-unchanged config/local.yml
# Resume normal tracking

git update-index --chmod=+x scripts/deploy.sh
# Mark a script executable in the index

git update-index --refresh
# Refresh stat info; useful after touching files

Errores comunes

--assume-unchanged is meant as a performance optimization, not as .gitignore for already-tracked files. If teammates need the file unchanged, use a config-template approach instead. Misuse causes bugs where tracked changes go unnoticed.

Comandos relacionados

git add, git rm, git ls-files, git read-tree