Skip to content

Instantly share code, notes, and snippets.

@alaindet
Created September 7, 2022 12:46
Show Gist options
  • Save alaindet/a7bcd5805d92d5ca826b4448d5411986 to your computer and use it in GitHub Desktop.
Save alaindet/a7bcd5805d92d5ca826b4448d5411986 to your computer and use it in GitHub Desktop.
Freeze/unfreeze files

How to freeze files in Git

Frozen files are different that ignored files, so that

  • Ignored files are listed in .gitignore and Git never picks them up
  • Frozen files are previously committed files which are later ignored by Git

Frozen files can be configuration files that are frequently changed with secret values and should not be committed.

How to freeze files

git update-index --skip-worktree PATH_TO_FILE

How to unfreeze files

git update-index --no-skip-worktree PATH_TO_FILE

How to list frozen files

git ls-files -v . | grep ^S
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment