0

I have a directory in a git repo that is set to ignore all files except certain patterns like so:

# ignore all files except for template config files
!/

/*
!exception_dir/
!.gitignore
!init.sh
!blah.template.json

I have added a subdirectory that I would like to set exceptions for. Like so:

# ignore all files except for template config files
!/

/*
!exception_dir/
!.gitignore
!init.sh
!blah.template.json
!exception2_subdir/

As expected, the above syntax does not ignore all files within 'exception2_subdir'. However, I only want certain files added to git within exception2_subdir. I found the following syntax via google searches:

# ignore all files except for template config files
!/

/*
!exception_dir/
!.gitignore
!init.sh
!blah.template.json
!exception2_subdir/add_this_template_file_to_git_please
!exception2_subdir/add_this_template_file_to_git_please2

This syntax doesn't seem to be working. When I try to manually add 'exception2_subdir/add_this_template_file_to_git_please', I get the error message that this path is ignored by my .gitignore file. Any tips?

Please note that this is not my architecture so I have limited ability to change the structure.

Thanks!

Eric

brbcoffee
  • 85
  • 5
  • Possible duplicate of [.gitignore exclude folder but include specific subfolder](https://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder) – phd Oct 20 '17 at 21:37

1 Answers1

0

I needed to explicitly unignore the dir, then ignore the dir, then unignore specific files :/

# ignore all files except for template config files
!/

/*
!exception_dir/
!.gitignore


exception_dir/*
!exception_dir/add_this_template_file_to_git_please
!exception_dir/add_this_template_file_to_git_please2
brbcoffee
  • 85
  • 5