I've been pulling out my hair researching the net and various docs about .gitignore files. I'm a bit of a n00b with Unix/Terminal (using Mac OS X) and I can't for the life of me figure out how to ignore a folder's contents (any kind of content, be it a file or another folder, no matter how deep it is).
I'm working on a project that generates image files within a consistent file structure, except we're getting merge conflicts regarding user permissions. I'd like to ignore the folders that contain the generated images so we can avoid any further hair-pulling having to adjust permissions on a per-pull basis. I'm just having trouble getting the .gitignore file to work, so I need to figure out the right pattern for folder's content matching. I want it to be general enough in that it can easily encompass the whole site (so if any folder contains a particular folder name, it will ignore its contents).
I've tried:
# Images
resample/
resize/
min/
And...
# Images
resample/*
resize/*
min/*
And...
# Images
*/resample/*
*/resize/*
*/min/*
And many more combinations with unsatisfactory results. I never got the foldername/**/*
pattern to ever work either. Any help regarding this issue would be most appreciated!
Thanks to the previous posters for their help. After some further delving in, I discovered how to properly implement the new .gitignore
rules. The problem was that previously the images were being tracked so I had to remove the reference to the files within the .git/index
file, like so...
// Remove all tracked files from the index
// (doesn't remove the file, just the reference)
git rm -r --cached .
// Add all the files again
// (files and folders specified by .gitignore aren't added to the index)
git add .
// Commit to save changes
git commit -am "gitignore update"
You're looking for gitignore
A gitignore file specifies intentionally untracked files that git should ignore. Note that all the gitignore files really concern only files that are not already tracked by git;
If your file or folder is in the repository it must be deleted from the repository for it to be ignorable.
Also watch out for case sensitivity in your patterns.
Your first list should work assuming those folders are not under version control currently.
# Images
resample/
resize/
min/
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