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
| Flag | Meaning |
|---|---|
| --chmod=+x | record the executable bit, useful from Windows |
| --skip-worktree | let you keep local edits to a tracked file |
| --no-skip-worktree | undo that |
| --assume-unchanged | promise you will not edit it, as a speed hint only |
| --no-assume-unchanged | undo that |
| --refresh | update stat information after a filesystem change |
Examples
git update-index --chmod=+x scripts/deploy.shstages the executable bit so CI can run it
git update-index --skip-worktree config/local.jsonkeeps your local edits out of every diff
git update-index --no-skip-worktree config/local.jsonputs 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