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

gitignore 规则问题

  •  
  •   tanteng · Dec 12, 2015 · 2694 views
    This topic created in 3799 days ago, the information mentioned may be changed or developed.

    加入一个.gitignore 文件:

    .idea/
    venv/
    *.pyc
    *.pyo

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

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

    4 replies    2015-12-12 17:44:34 +08:00
    willxiang
        1
    willxiang  
       Dec 12, 2015 via iPhone
    用感叹号。
    搜一下用法,自己开个 project 建几个文件夹,写个测试 push 一下就明白了。
    msg7086
        2
    msg7086  
       Dec 12, 2015
    Let me google it for you: /t/145660
    fds
        3
    fds  
       Dec 12, 2015
    有些蛋疼……虽然支持但也不建议这么用呀。
    tanteng
        4
    tanteng  
    OP
       Dec 12, 2015
    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/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   922 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 21:17 · PVG 05:17 · LAX 14:17 · JFK 17:17
    ♥ Do have faith in what you're doing.