In a project using Git i have a folder that is added to .gitignore. But i needed to include a subfolder that is tracked by git.
What the folder structure looked like:
- Sites
- -all
-
-
- -files
-
-
-
-
-
- -private
-
-
-
-
-
-
-
-
-
- -newspilot
-
-
-
-
-
- -default
-
-
- -files
-
-
-
-
-
- -private
-
-
-
-
-
-
-
-
-
- -newspilot
-
-
-
-
-
I needed to keep files in the newspilot folder but the files folder and its subfolders was ignored like this in the .gitignore: sites/*/files
I also didn’t want the files that exists in files and private. And this was the solution:
Git ignore and exclude
The first line ignores all files and folders in files.
The second line excludes the private folder.
The third line ignores all files and folder in private.
And finally the last line excludes the newspilot folder.