-1

I ignore the folder "Debug" using .gitignore. But in "Debug" there is a folder "Docs" that I want to keep (also the files in there). So how do I have to configure .gitignore to only keep the folder "Docs" with its files but ignore all the rest of "Debug"?

  • Not sure that can be done with .gitignore alone, if I remember correctly, you cannot re-include files if you have excluded a parent directory. You can always just forcibly track the files, once tracked they will stay tracked, using `git add -f path-to-file(s)`, but I'm not sure you can easily manage this. Why is the folder placed under `Debug`, and is this a .NET Project? If it is, then you should **definitely** not put files you want to keep inside the `Debug` folder. – Lasse V. Karlsen Oct 12 '18 at 08:14
  • Later those files will be in the ApplicationStartupPath. Yes, it is a .NET-project. Since "Debug" is the StartupPath at the moment, the files are kept there. – JimPanseKing Oct 12 '18 at 08:19
  • You should change your program so that you have a configuration somewhere that specifies where the documents can be found, it doesn't have to be configurable by the end user but could detect DEBUG vs. PRODUCTION and pick the right folder depending on that. This would allow you to place the folders, during debug and development, outside of the Debug folder. – Lasse V. Karlsen Oct 12 '18 at 08:21

1 Answers1

1

It is very simple. Just follow these steps:

  1. Remove the entry of your debug folder from your .gitignore file.
  2. In the debug folder, create a new .gitignore file and write these two lines in it.

* !Docs

It will ignore everything in your debug folder except docs folder and its content.

Aakash Pahuja
  • 469
  • 4
  • 10