Skip to content

Instantly share code, notes, and snippets.

@ncimino
Last active October 11, 2015 19:08
Show Gist options
  • Save ncimino/3905536 to your computer and use it in GitHub Desktop.
Save ncimino/3905536 to your computer and use it in GitHub Desktop.
Git Ignore All Except
*
!/a
/a/*
!/a/b
/a/b/*
!/a/b/c
/a/b/c/*
!/a/b/c/foo
# don't forget this one
!.gitignore
@ncimino
Copy link
Author

ncimino commented Jan 20, 2013

This is what is needed to mask all files in all nested directories, except the foo file:

don't ignore dir a

!/a

ignore everything in dir a

/a/*

don't ignore dir b

!/a/b

ignore everything in dir a

/a/b/*

don't ignore dir c

!/a/b/c

ignore everything in dir a

/a/b/c/*

don't ignore file foo

!/a/b/c/foo

don't forget this one

!.gitignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment