Skip to content

Instantly share code, notes, and snippets.

@felixpenrose
Forked from hieblmedia/.gitignore
Created June 16, 2020 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixpenrose/11a77248db28c5dc2a1f457e9c9abb5d to your computer and use it in GitHub Desktop.
Save felixpenrose/11a77248db28c5dc2a1f457e9c9abb5d to your computer and use it in GitHub Desktop.
Gitignore - Exclude all except specific subdirectory
#
# If all files excluded and you will include only specific sub-directories
# the parent path must matched before.
#
/**
!/.gitignore
###############################
# Un-ignore the affected subdirectory
!/libraries/
# Ignore subdirectory and all including directories and files to match pattern as valid for the next pattern
/libraries/**
# This pattern only works with the two previous patterns
# (i remember it was working alone on older git versions)
!/libraries/myLibrary/
###############################
# Another example
!/templates/
/templates/**
!/templates/myTemplate/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment