1

I have a project which tree structure looks like this:

+ /Root - .gitignore + - - /Folder A - - - .gitignore <--- this fellow + - - - /bin - - - - - fileA + - - - - fileB + - - - /Folder AA + - - /FolderB + - - - /bin ...

The .gitignore in the root-folder has a lot of rules, among them is to ignore all /bin-folders. However, in my FolderA I would like everything to stay as it is - all the way down in that folder. FolderB/bin on the other hand should be ignored.

I know this is possible by adding another .gitignore in FolderA, and let this override the root folder's .gitignore. But I can't remember how.

What should I write in FolderA/.gitignore?

Edit: In other words: "FolderA is a sacred folder, and must have all files in it stay in it, disregarding what any other .gitignore-files must say"

Rasmus Bækgaard
  • 1,748
  • 2
  • 10
  • 13

2 Answers2

1

Override the root .gitignore in /FolderA/.gitignore using the include syntax:

!file_that_should_not_be_ignored
!folder_that_should_not_be_ignored
Simon Kuang
  • 3,870
  • 4
  • 27
  • 53
  • It does not work. I tried running a ``git rm . -r --cached`` followed by a ``git add -A .`` afterwards, but it does not take all the files. – Rasmus Bækgaard Aug 24 '17 at 07:13
1

Solution found:

In the .gitignore file added in the folder needed to be excluded, the following line is added as the only line:

!*/

Rasmus Bækgaard
  • 1,748
  • 2
  • 10
  • 13