Skip to content
Latchkey

git update-index Command in CI

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.

Key takeaways

  • git update-index --chmod=+x fixes executable bits lost on permission-blind filesystems.
  • --refresh clears spurious modified flags caused by stat differences after checkout.
  • assume-unchanged and skip-worktree are local-only hints, not a way to ignore committed files.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →