tags:

views:

320

answers:

3

I have a git directory which contains the a whole bunch of files and then has a directory called 'sessions'. 'sessions' contains cookie information for my web.py program.

I need the folder 'sessions' to remain in the git repository because without the folder the program does not function correctly. I don't need the actual contents of folder being stored in the git directory.

So the question is:

How can I get git to ignore the contents of a folder but not the folder itself?

A: 

gitignore(5) is the man page you're looking for.

If everyone read man pages there wouldn't be a need for stackoverflow
Singletoned
In addition, gitignore man page does not answer the question.
Adam Nelson
+4  A: 

If I'm remembering correctly, you can do this by creating a .gitignore file in the sessions folder with "*" as its contents.

edit: Apparently the contents of .gitignore must be [^.]* instead of *. Thanks @Wergan.

ceejayoz
I tried this as a test, but it didn't work. I must've done something wrong.
dylanfm
I got it working but I had to use '[^.]*' instead of '*'
Wergan
A: 

Since July 2007, gitignore does describe the exclusion patterns.

If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory.

In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git).

As illustrated by this thread, that pattern was not always expressed with a '/' for matching directory.

VonC