0

This question is very similar to the following:

https://stackoverflow.com/a/8025106/882428

The difference being that I'm trying to do it for a single directory rather than the entire project.

I have the following directory structure:

/temp/
/temp/local/
/temp/remote/

Each directory has files within it that I would not like tracked, but I also include a .keep file to ensure the folders exist, but there can also be any number of other folders within /temp/.

I've tried dozens of configurations but either get nothing new in my git status or all of the files.

Community
  • 1
  • 1
Chords
  • 6,720
  • 2
  • 39
  • 61

1 Answers1

0

How about this .gitignore:

/temp/local/*
!/temp/local/.keep
/temp/remote/*
!/temp/remote/.keep

It should ignore everything but the .keep file in those directories.

You could also simply use this .gitignore:

/temp/local/
/temp/remote/

In this case you have to add the files explicitly using something like git add temp/{local,remote}/.keep.

But most of the time the even better approach is changing you application to create all the directories it needs.

michas
  • 25,361
  • 15
  • 76
  • 121