tags:

views:

70

answers:

2

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!

+1  A: 

http://www.kernel.org/pub/software/scm/git/docs/gitignore.html

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/
kevpie
Thanks for that. After some further research and experimentation, I found out a couple interesting things...
scheurbert
+1  A: 

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"
scheurbert
Thanks for adding this. I am about to start using git myself, this is all need to know stuff.
kevpie