1

I have a folder logs/ which was added in .git There may be files and sub-folders as well inside logs/ I want to ignore everything inside logs/ but not the logs/ folder itself.

I found following command to remove previously added file:

git rm --cached filename

but not able to ignore files and folders inside logs/ I also tried git rm --cached logs/*

but it shows all files inside it as deleted

but of no help :(

I simply want git to ignore everything inside logs/

Ashutosh
  • 4,371
  • 10
  • 59
  • 105

1 Answers1

2

If you want to ignore everything inside a directory but not the directory itself, you might need to include at least one non-ignored file inside that directory.

For instance, like in this answer, you could create a .gitignore file inside of that directory that contains:

*
!.gitignore

Then add that file to your repository. Now the directory will be kept but git will only keep track of the .gitignore file inside of it.

user10186512
  • 453
  • 2
  • 7