How do you get git to ignore all contents of a directory?

后端 未结 3 1456
梦谈多话
梦谈多话 2020-12-13 06:11

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

相关标签:
3条回答
  • 2020-12-13 06:22

    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.

    0 讨论(0)
  • 2020-12-13 06:26

    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.

    0 讨论(0)
  • 2020-12-13 06:36

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

    0 讨论(0)
提交回复
热议问题