Skip to content

Instantly share code, notes, and snippets.

@alxpsr
Last active May 4, 2020 07:57
Show Gist options
  • Save alxpsr/6444edf383fa7a7f90f646054702571e to your computer and use it in GitHub Desktop.
Save alxpsr/6444edf383fa7a7f90f646054702571e to your computer and use it in GitHub Desktop.
Git sparse-checkout

GIT SPARSE-CHECKOUT

  1. cd <YOUR_REPO>
  2. git sparse-checkout init
  3. git sparse-checkout set <PATTERN>, where is pattern like gitignore-pattern
  4. Then git will create file at path YOUR_REPO/.git/info/sparse-checkout
  5. Your might edit this file with git sparse-checkout set or IDE, or via cli - echo !program.ts' > .git/info/sparse-checkout
  6. The logic of sparse-checkout file is the opposite of .gitignore - in sparse-checkout you should set folders that will be ENABLED (in other hand in .gitignore you should set folders that will be DISABLED)
  7. sparse-checkout will be apply ONLY for local repo (in other hand .gitignore will be apply to remote repo)

EXAMPLE

# enable all files but not program.ts
/*
!.program.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment