I've been looking around and just could not find the same scenario that I have. I have:
--public |--img |--logo (folder) |--post_image (folder) |--banner.jpg |--icon.ico |--image1.jpg |-........etc
I need to ignore the logo
and post_image
folders, but I want to keep every file that is inside img
folder. How would I go about it?
Right now I have **/public/img
but I feel is not the right approach!
Personal Ignore Rules Patterns that are specific to your local repository and should not be distributed to other repositories should be set in the . git/info/exclude file. For example, you can use this file to ignore generated files from your personal project tools.
Git ignore patterns An asterisk is a wildcard that matches zero or more characters. Prepending an exclamation mark to a pattern negates it. If a file matches a pattern, but also matches a negating pattern defined later in the file, it will not be ignored.
A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .
I found this to be simpler (at least in the case there are many subfolders):
public/img/*/
This will exclude all subfolders in public/img/
, but will not exclude the files in this folder.
You can put a .gitignore
file into any child directory, it doesn't have to be at the root. In your case, a .gitignore
file in the public/img
directory with the content:
logo post_image
would do the job.
For another approaches, you might want to look at:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With