使用.gitignore忽略多路径上的相同目录结构

时间:2014-07-06 15:02:20

标签: git gitignore smartgit

我有一个链接到Bitbucket的Git存储库的网站。此站点是多语言,但我只需要上传到存储库spanishenglish语言。这里的问题是在几条路径上存在相同的结构。请参阅下面的示例(在多路径上重复相同的语言结构):

system\
    cms\
    language\
        arabic\
        brazilian\
        chinese_simplified\
        chinese_traditional\
        czech\
        danish\
        dutch\
        english\
        finnish\
        french\
        german\
        greek\
        hebrew\
        hungarian\
        indonesian\
        italian\
        khmer\
        lithuanian\
        persian\
        polish\
        portuguese\
        russian\
        slovenian\
        spanish\
        swedish\
        thai\
        vietnamese\
    modules\
        addons\
            language\
                arabic\
                brazilian\
                chinese_simplified\
                chinese_traditional\
                czech\
                danish\
                dutch\
                english\
                finnish\
                french\
                german\
                greek\
                hebrew\
                hungarian\
                indonesian\
                italian\
                khmer\
                lithuanian\
                persian\
                polish\
                portuguese\
                russian\
                slovenian\
                spanish\
                swedish\
                thai\
                vietnamese\
        blog\
            language\
                ...
        comments\
            language\
                ...
        contact\
            language\
                ...
        files\
            language\
                ...
        keywords\
            language\
                ...
        maintenance\
            language\
                ...
        navigation\
            language\
                ...
        pages\
            language\
                ...
        permissions\
            language\
                ...
        redirects\
            language\
                ...
        search\
            language\
                ...
        settings\
            language\
                ...
        sitemap\
            language\
                ...
        streams_core\
            language\
                ...
        templates\
            language\
                ...
        users\
            language\
                ...
        variables\
            language\
                ...
        widgets\
            language\
                ...
        wysiwyg\
            language\
                ...

是否有任何方法或正则表达式.gitignore支持仅允许spanishenglish并省略其余内容?

编辑:toydarian解决方案 在@toydarian建议之后,我将这些行添加到.gitignore文件:

language/arabic/*
language/brazilian/*
language/chinese_simplified/*
language/chinese_traditional/*
language/czech/*
language/danish/*
language/dutch/*
language/finnish/*
language/french/*
language/german/*
language/greek/*
language/hebrew/*
language/hungarian/*
language/indonesian/*
language/italian/*
language/khmer/*
language/lithuanian/*
language/persian/*
language/polish/*
language/portuguese/*
language/russian/*
language/slovenian/*
language/swedish/*
language/thai/*
language/vietnamese/*

但是如图所示,它不起作用,还有其他任何建议或方式吗?

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以在shell中使用通配符。 look here
不支持正则表达式。

因此,唯一要为每种语言添加<language>/*,您要排除在.gitignore上 这将排除<language>

的每个子目录

<language>是特定语言的占位符,例如&#34;德语&#34;