ignoring folders in mercurial

后端 未结 4 1108
余生分开走
余生分开走 2020-12-15 17:07

Caveat: I try all the posibilities listed here: How can I ignore everything under a folder in Mercurial.
None works as I hope.

I want to ignor

相关标签:
4条回答
  • 2020-12-15 17:15

    Try it without the slash after the caret in the regexp version.

    ^test/
    

    Here's a test:

    ~$ mkdir hg-folder-ignore
    ~$ cd hg-folder-ignore
    ~/hg-folder-ignore$ echo '^test/' > .hgignore
    ~/hg-folder-ignore$ hg init
    ~/hg-folder-ignore$ mkdir test
    ~/hg-folder-ignore$ touch test/ignoreme
    ~/hg-folder-ignore$ mkdir -p srcProject/test/TestManager
    ~/hg-folder-ignore$ touch srcProject/test/TestManager/dont-ignore
    ~/hg-folder-ignore$ hg stat
    ? .hgignore
    ? srcProject/test/TestManager/dont-ignore
    

    Notice that ignoreme isn't showing up and dont-ignore is.

    0 讨论(0)
  • 2020-12-15 17:15

    You can use zero-width negative look-ahead and look-behind assertions to specify that you want to ignore test only when it's not preceded by srcProject and not followed by TestManager:

    syntax: regexp
    (?<!srcProject\\)test\\(?!TestManager)
    

    Mercurial uses Python regular expressions, so you can find more info on zero-width assertions in the Python docs: https://docs.python.org/library/re.html#regular-expression-syntax

    0 讨论(0)
  • 2020-12-15 17:23

    Both cases worked for me (on linux and windows):

    syntax: regexp
    ^backup/     #root folder
    nbproject/   #any folder
    

    or

    syntax: glob
    ./backup/*   #root folder
    nbproject/*  #any folder
    

    However, it wasn't before I added a link to .hgignore file to .hgrc file in my repo:

    [ui]
    ignore = .hg/.hgignore
    

    Also worth mentioning that mercurial ignores files that it is not currently tracking, which are those added before you configured it to ignore them. So, don't be put off by hg status saying some filed are M (modified) or ! (missing) in the folders that you have just added to the ignore list!

    0 讨论(0)
  • 2020-12-15 17:25

    Create .hgignore file under root directory of the repository

    Now add the following contents in the file .

    syntax: glob

    bin/**

    *.DS_Store

    This will remove the bin directory and all the *.DS_Store files from the repository

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