git-update-index - Linux


git-update-index updates the index with the current contents of the working tree and the cache. This allows you to stage changes for commit, update ignored files, or remove files from the index.


git update-index [--[no-]assume-unchanged <paths>...]
              [--add|--rm] <paths>...


  • --[no-]assume-unchanged: Mark paths as assumed-unchanged. This prevents changes to the paths from being automatically staged.
  • --[no-]skip-worktree-refresh: Skip refreshing the index from the working tree.
  • -q|--quiet: Suppress progress messages.
  • -z|--null: Use NUL-separated paths.
  • -f|--force-remove: Force removal of paths from the index.
  • -u|--unmerged: List unmerged paths.
  • -A|--all: Update the index for all tracked paths in the working tree.
  • -R|--remove: Remove paths from the index.
  • -t|--refresh: Refresh the index using the cache.
  • --add: Stage the specified paths for commit.
  • --rm: Remove the specified paths from the index.


Stage a single file for commit:

git update-index --add path/to/file.txt

Stage all tracked files for commit:

git update-index -A

Remove a file from the index:

git update-index --remove path/to/file.txt

Refresh the index using the cache:

git update-index -t

Common Issues

  • Path not found: Ensure that the specified paths exist in the working tree or cache.
  • Cannot remove a modified file: Use git add -A to stage any uncommitted changes before removing it from the index.
  • Unmerged paths: Resolve any merge conflicts before updating the index.


git-update-index can be used in conjunction with other commands:

  • git commit -i: Stage changes before editing the commit message.
  • git diff: Show differences between the working tree and the index.
  • git clean -f: Remove untracked files from the working tree and update the index.

Related Commands

  • git-add
  • git-rm
  • git-status