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?
There is no explicit git ignore command; instead, the . gitignore file must be edited and committed by hand when you have new files that you wish to ignore. The . gitignore files hold patterns that are matched against file names in your repository to determine whether or not they should be ignored.
Add a sessions/.gitignore file with
* !.gitignore
The second line tells git not to ignore the .gitignore file, so the folder is not empty but everything else is ignored.
If I'm remembering correctly, you can do this by creating a .gitignore
file in the sessions
folder with [^.]*
as its contents.
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