V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
tanteng
V2EX  ›  git

gitignore 规则问题

  •  
  •   tanteng · 2015-12-12 14:24:14 +08:00 · 2179 次点击
    这是一个创建于 3059 天前的主题,其中的信息可能已经有所发展或是发生改变。

    加入一个.gitignore 文件:

    .idea/
    venv/
    *.pyc
    *.pyo

    这样会忽略 venv 文件夹下所有的文件,
    venv/
    venv/folder1
    venv/folder2
    venv/file1.py
    venv/file2.py

    我想忽略 venv 下但除了 folder2 子文件夹,该怎样写规则?谢谢!

    4 条回复    2015-12-12 17:44:34 +08:00
    willxiang
        1
    willxiang  
       2015-12-12 14:55:34 +08:00 via iPhone
    用感叹号。
    搜一下用法,自己开个 project 建几个文件夹,写个测试 push 一下就明白了。
    msg7086
        2
    msg7086  
       2015-12-12 15:06:27 +08:00
    Let me google it for you: /t/145660
    fds
        3
    fds  
       2015-12-12 17:31:17 +08:00
    有些蛋疼……虽然支持但也不建议这么用呀。
    tanteng
        4
    tanteng  
    OP
       2015-12-12 17:44:34 +08:00
    http://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder

    # you can skip this first one if it is not already excluded by prior patterns
    !application/

    application/*
    !application/language/

    application/language/*
    !application/language/gr/
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2987 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 14:16 · PVG 22:16 · LAX 07:16 · JFK 10:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.