V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
hustlzp
V2EX  ›  git

[gitignore 求解惑] admin.py 为什么会匹配到 controllers/admin.py

  •  
  •   hustlzp · Mar 17, 2014 · 3201 views
    This topic created in 4427 days ago, the information mentioned may be changed or developed.
    发现在.gitignore中写一行:

    admin.py

    也会匹配到子目录下的admin.py(比如controllers/admin.py)。

    于是去 http://git-scm.com/docs/gitignore 好好看了下,这一条应该是适用我的情况的:

    If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file).

    就是说规则中不带/的就按照shell glob来,即按照glob规则和相对于.gitignore的所有pathname进行匹配。但是照这样来说,应该是*admin.py匹配controllers/admin.py,而 admin.py不应该匹配上这个pathname啊。

    不知道是我哪里理解错了还是什么的,求解惑...
    2 replies    1970-01-01 08:00:00 +08:00
    9hills
        1
    9hills  
       Mar 17, 2014
    Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file. These patterns match relative to the location of the .gitignore file. A project normally includes such .gitignore files in its repository, containing patterns for files generated as part of the project build.

    也就是会读上一层以及上上一层直到toplevel的.gitignore

    你在controllers目录下,先读本目录的.gitignore,没有就把上一层的.gitignore读下来。。也就是说相当于你在controllers目录下的.gitignore下加了一行 admin.py
    123123
        2
    123123  
       Mar 17, 2014
    意思是你要写 「/admin.py
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1054 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:32 · PVG 07:32 · LAX 16:32 · JFK 19:32
    ♥ Do have faith in what you're doing.