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
git ls-files Command: List Tracked Files in CIgit ls-files lists files in the index. Reference for listing tracked, ignored, or modified files to drive lin…
git status Command: Check Tree State in CIgit status shows working tree and index state. Reference for --porcelain, the stable machine-readable format…
git diff Command: Detect Changes in CIgit diff shows changes between commits or the working tree. Reference for --name-only, --stat, and --exit-cod…
git config Command: Configure Git in CIgit config reads and writes Git settings. Reference for user.email, --global, and credential.helper to set up…