git-update-index
Manage files in the Git index
TLDR
Pretend that a modified file is unchanged (git status will not show this as changed)
SYNOPSIS
git update-index [options] [--] [file...]
PARAMETERS
--add
Add files to index, fail if already tracked
--remove
Remove files from index if missing from working tree
--refresh
Update stat info without changing index entries
--cacheinfo
Directly insert blob/subtree/commit entry into index
--chmod=(+|-)x
Set or clear executable bit in index
--assume-unchanged
Mark entry as unchanged to skip updates (performance)
--no-assume-unchanged
Clear assume-unchanged flag
--skip-worktree
Ignore changes to entry (local config override)
--no-skip-worktree
Clear skip-worktree flag
--really-refresh
Refresh even if stat info matches
--unmerged
Only for files with unmerged entries
--info-only
Only update stat info, not content
--stdin
Read list of paths from stdin
--index-info
Read index format from stdin
--q, --quiet
Suppress output messages
--force-remove
Remove files even if modified
--ignore-missing
Ignore missing files
DESCRIPTION
The git update-index command updates the Git index (staging area) with information from the current working tree. It is a low-level porcelain command primarily used to register file contents in the index before a commit. While higher-level commands like git add and git rm invoke it indirectly, git update-index offers fine-grained control over index entries.
By default, it reads specified files or all tracked files if none are given, computes their object IDs (blobs), and updates the index accordingly. It detects changes by comparing stat info and content. Options allow adding untracked files, removing tracked ones, assuming unchanged status for performance, or directly inserting cache entries.
Common uses include scripting Git operations, handling special files like symlinks or executables, or refreshing index without staging changes. It does not create commits or modify the working tree—only the index. Use cautiously, as misuse can lead to lost staging information.
This command is essential for understanding Git's index model, enabling efficient partial commits and sparse checkouts.
CAVEATS
Avoid direct use when git add suffices; can overwrite staged changes. Does not recurse into submodules by default. Assume-unchanged and skip-worktree are local only and can cause issues in clones.
EXIT STATUS
0 if all operations succeed; 1 on errors like unreadable files.
GIT INDEX MODEL
Operates on .git/index file, using stat + SHA-1 for change detection.
HISTORY
Introduced in Git 0.99 (April 2005) by Linus Torvalds as core porcelain plumbing. Evolved with index features like assume-unchanged (v1.5.3, 2007) and skip-worktree (v1.7.0, 2010). Remains stable for scripting.
SEE ALSO
git-add(1), git-rm(1), git-ls-files(1), git-status(1), git-commit(1)


