Search code examples
gitgitignoresmartgit

Ignore the same directory structure on multiples path with .gitignore


I have a website linked to Git repository at Bitbucket. This site is multi language but I need to upload to repository only spanish and english languages. The problem here is that same structure is present on several paths. See the example below (the same language structure is repeated on multiples paths):

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\
                ...

Is there any way, or regex if it's supported on .gitignore to allow only spanish and english and ommit the rest of them?

Edit: toydarian solution Following @toydarian suggestion I added this lines to .gitignore file:

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/*

But as image shows, it's not working, any other advice or way?

enter image description here


Solution

  • You can use wildcards as you can use in the shell. look here
    Regular expressions are not supported.

    So the only thing is to add <language>/* for every language, you want to exclude to your .gitignore
    That will exclude every sub-directory of <language>

    <language> is a placeholder for a specific language like "german"