你如何让git忽略目录中的所有内容? [英] How do you get git to ignore all contents of a directory?
问题描述
我有一个包含大量文件的git目录,然后有一个名为'sessions'的目录。 '会话'包含我的web.py程序的cookie信息。
我需要将文件夹'会话'保留在git存储库中,因为没有该文件夹,程序无法正常运行。我不需要将文件夹的实际内容存储在git目录中。
所以问题是:
如何让git忽略文件夹的内容而不是文件夹本身?
如果我记得正确地,您可以通过在会话
文件夹中使用创建一个 .gitignore
^。] *
作为其内容。 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?
If I'm remembering correctly, you can do this by creating a .gitignore
file in the sessions
folder with [^.]*
as its contents.
这篇关于你如何让git忽略目录中的所有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!