Skip to content

Instantly share code, notes, and snippets.

@kherge
Created May 20, 2025 22:23
Show Gist options
  • Save kherge/adc471ecba6c36549ec7c5f9553f146d to your computer and use it in GitHub Desktop.
Save kherge/adc471ecba6c36549ec7c5f9553f146d to your computer and use it in GitHub Desktop.
Git allow instead of ignore
# Convert to allow list.
*
# Allow ignore lists.
!.gitignore
# Convert to allow list.
*
# Allow ignore lists.
!.gitignore
# Allow package manifest.
!/Cargo.toml
!/Cargo.lock # delete if library
# Allow source files.
!/src/
!/src/**/
!/src/**/*.rs

Allow

I'm noticing that ignore rules are more complicated than allow rules in Git. The .gitignore file flips the script and requires that anything to be committed to be allowed first.

  • .gitignore &emdash; a basic example of an allow list
  • .gitignore-rs &emdash; an example for a Rust project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment