0

I want to gitignore all files inside my public/images/Users/ directory but I want that path to be tracked on my repository so that other collaborators will not create new folders on their machines. I have this line on my .gitignore file public/images/Users/* but this line ignores all from images folder. What is the best way to achieve this? Thanks. By the way, my project is on Laravel framework.

Magnus Bäck
  • 11,381
  • 3
  • 47
  • 59
Jay Marz
  • 1,861
  • 10
  • 34
  • 54
  • Git doesn't track directories at all. They get created as needed to hold files. I have voted to close this question as a duplicate, as this has already been asked and answered dozens of times on SO. – ChrisGPT was on strike Dec 21 '14 at 20:56
  • possible duplicate of [How to track directories but not their files with Git?](http://stackoverflow.com/questions/5091017/how-to-track-directories-but-not-their-files-with-git) – ChrisGPT was on strike Dec 21 '14 at 20:56

1 Answers1

1

To illustrate the practice of adding placeholder files in folders you want cloned (but with an ignored content), consider that the laravel project uses an original variation of that technique:

See the laravel/app/storage/logs folder.

The .gitignore itself is the placeholder file which allows its parent folder to be versioned.

But its content is:

*
!.gitignore

It ignores every file within the logs folder, except for itself.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250