# git update-index Command in CI

> git update-index manipulates the staging area directly. Reference for --assume-unchanged, --chmod, and --refresh used in CI to control tracked file state.

Source: https://latchkey.dev/learn/command-reference/git-update-index-command-reference  
Updated: 2026-06-26

git update-index is the plumbing command that registers file contents and flags in the index.

Most workflows stage via git add, but CI occasionally needs lower-level control: fixing a file mode, or telling Git to stop noticing changes to a file. update-index provides it.

## Common flags

- `--chmod=+x <file>` - set the executable bit on a tracked file in the index
- `--assume-unchanged <file>` - tell Git to skip checking a file for changes
- `--no-assume-unchanged <file>` - undo assume-unchanged
- `--skip-worktree <file>` - ignore local edits to a tracked file
- `--refresh` - refresh the stat information in the index to match the working tree
- `--add` / `--remove` - explicitly add or remove a path

## Example

```shell
# Make a committed script executable on a case-insensitive runner
git update-index --chmod=+x scripts/deploy.sh
git commit -m "Mark deploy.sh executable"
```

## In CI

git update-index --chmod=+x reliably sets the executable bit even on filesystems that do not preserve permissions, fixing "permission denied" on committed scripts. Use --refresh to clear false "modified" stat differences after a checkout on some runners.

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### git update-index Command in CI?

Most workflows stage via git add, but CI occasionally needs lower-level control: fixing a file mode, or telling Git to stop noticing changes to a file. update-index provides it.

### In CI?

git update-index --chmod=+x reliably sets the executable bit even on filesystems that do not preserve permissions, fixing "permission denied" on committed scripts. Use --refresh to clear false "modified" stat differences after a checkout on some runners.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
