Home·Terminal commands

git update-index

git

Usage

git update-index [--skip-worktree|--chmod=+x] <file>

Edits the index directly; the marks are local and never pushed, and the one that keeps your local edits to a tracked config file is --skip-worktree, not --assume-unchanged.

Common flags

FlagMeaning
--chmod=+xrecord the executable bit, useful from Windows
--skip-worktreelet you keep local edits to a tracked file
--no-skip-worktreeundo that
--assume-unchangedpromise you will not edit it, as a speed hint only
--no-assume-unchangedundo that
--refreshupdate stat information after a filesystem change

Examples

git update-index --chmod=+x scripts/deploy.sh

stages the executable bit so CI can run it

git update-index --skip-worktree config/local.json

keeps your local edits out of every diff

git update-index --no-skip-worktree config/local.json

puts the file back under normal tracking

The confusion is that undo has several shapes — moving where a branch points is not the same as adding a commit that reverses it.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does git update-index do?

Edits the index directly; the marks are local and never pushed, and the one that keeps your local edits to a tracked config file is --skip-worktree, not --assume-unchanged.

Q. How do I type it?

git update-index [--skip-worktree|--chmod=+x] <file> — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

6 are listed here; the full set is in man git. This command sits under git.

Related commands

man page: man git-update-index