Global gitignore - how to exclude a single specific folder










1














I would like to exclude all .idea files in a specific folder through a global .gitignore (located in ~/.gitignore_global).



I tried to put a following lines there:



# assuming .gitignore_global understands absolute paths
/Users/<my home folder>/Desktop/Dev/**/.idea

# assuming .gitignore_global takes a location of global gitignore (~) as a root
Desktop/Dev/**/.idea


Neither seem to work (however, adding just .idea works, so this global gitignore is used by git - however, I don't want to ignore .idea for my personal projects in other folders).



How are global excludes supposed to work?



Which folder is considered by git as a 'root'? (in case of normal .gitignore, all paths are relative to a repository root, but global gitignore seems to work differently).



Thanks!



I'm on a Mac, git version 2.17.2 (Apple Git-113)



EDIT: As per @torek:




The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




So, there is no way to accomplish this, as there is no way to check the path of a whole project.










share|improve this question























  • As an alternative, you could put !.idea/ rule in your personal project's .gitignore. That will cancel the ignore rule defined globally, and you will be able to commit your .idea directory
    – Antwane
    Nov 12 at 10:09







  • 1




    The global gitignore is treated as if it were in the root Git directory (the work-tree top level).
    – torek
    Nov 12 at 10:09










  • I.e., just /.idea/ should work.
    – phd
    Nov 12 at 11:15










  • @torek Aha! This explains every behavior I didn't understand. And so, sadly, it isn't possible to accomplish what I want then.
    – Tomáš Kafka
    Nov 13 at 11:54










  • @Antwane Thanks, it's a hack, but it seems like the only possible solution.
    – Tomáš Kafka
    Nov 13 at 11:55















1














I would like to exclude all .idea files in a specific folder through a global .gitignore (located in ~/.gitignore_global).



I tried to put a following lines there:



# assuming .gitignore_global understands absolute paths
/Users/<my home folder>/Desktop/Dev/**/.idea

# assuming .gitignore_global takes a location of global gitignore (~) as a root
Desktop/Dev/**/.idea


Neither seem to work (however, adding just .idea works, so this global gitignore is used by git - however, I don't want to ignore .idea for my personal projects in other folders).



How are global excludes supposed to work?



Which folder is considered by git as a 'root'? (in case of normal .gitignore, all paths are relative to a repository root, but global gitignore seems to work differently).



Thanks!



I'm on a Mac, git version 2.17.2 (Apple Git-113)



EDIT: As per @torek:




The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




So, there is no way to accomplish this, as there is no way to check the path of a whole project.










share|improve this question























  • As an alternative, you could put !.idea/ rule in your personal project's .gitignore. That will cancel the ignore rule defined globally, and you will be able to commit your .idea directory
    – Antwane
    Nov 12 at 10:09







  • 1




    The global gitignore is treated as if it were in the root Git directory (the work-tree top level).
    – torek
    Nov 12 at 10:09










  • I.e., just /.idea/ should work.
    – phd
    Nov 12 at 11:15










  • @torek Aha! This explains every behavior I didn't understand. And so, sadly, it isn't possible to accomplish what I want then.
    – Tomáš Kafka
    Nov 13 at 11:54










  • @Antwane Thanks, it's a hack, but it seems like the only possible solution.
    – Tomáš Kafka
    Nov 13 at 11:55













1












1








1







I would like to exclude all .idea files in a specific folder through a global .gitignore (located in ~/.gitignore_global).



I tried to put a following lines there:



# assuming .gitignore_global understands absolute paths
/Users/<my home folder>/Desktop/Dev/**/.idea

# assuming .gitignore_global takes a location of global gitignore (~) as a root
Desktop/Dev/**/.idea


Neither seem to work (however, adding just .idea works, so this global gitignore is used by git - however, I don't want to ignore .idea for my personal projects in other folders).



How are global excludes supposed to work?



Which folder is considered by git as a 'root'? (in case of normal .gitignore, all paths are relative to a repository root, but global gitignore seems to work differently).



Thanks!



I'm on a Mac, git version 2.17.2 (Apple Git-113)



EDIT: As per @torek:




The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




So, there is no way to accomplish this, as there is no way to check the path of a whole project.










share|improve this question















I would like to exclude all .idea files in a specific folder through a global .gitignore (located in ~/.gitignore_global).



I tried to put a following lines there:



# assuming .gitignore_global understands absolute paths
/Users/<my home folder>/Desktop/Dev/**/.idea

# assuming .gitignore_global takes a location of global gitignore (~) as a root
Desktop/Dev/**/.idea


Neither seem to work (however, adding just .idea works, so this global gitignore is used by git - however, I don't want to ignore .idea for my personal projects in other folders).



How are global excludes supposed to work?



Which folder is considered by git as a 'root'? (in case of normal .gitignore, all paths are relative to a repository root, but global gitignore seems to work differently).



Thanks!



I'm on a Mac, git version 2.17.2 (Apple Git-113)



EDIT: As per @torek:




The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




So, there is no way to accomplish this, as there is no way to check the path of a whole project.







git gitignore






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 11:56

























asked Nov 12 at 10:02









Tomáš Kafka

2,46252942




2,46252942











  • As an alternative, you could put !.idea/ rule in your personal project's .gitignore. That will cancel the ignore rule defined globally, and you will be able to commit your .idea directory
    – Antwane
    Nov 12 at 10:09







  • 1




    The global gitignore is treated as if it were in the root Git directory (the work-tree top level).
    – torek
    Nov 12 at 10:09










  • I.e., just /.idea/ should work.
    – phd
    Nov 12 at 11:15










  • @torek Aha! This explains every behavior I didn't understand. And so, sadly, it isn't possible to accomplish what I want then.
    – Tomáš Kafka
    Nov 13 at 11:54










  • @Antwane Thanks, it's a hack, but it seems like the only possible solution.
    – Tomáš Kafka
    Nov 13 at 11:55
















  • As an alternative, you could put !.idea/ rule in your personal project's .gitignore. That will cancel the ignore rule defined globally, and you will be able to commit your .idea directory
    – Antwane
    Nov 12 at 10:09







  • 1




    The global gitignore is treated as if it were in the root Git directory (the work-tree top level).
    – torek
    Nov 12 at 10:09










  • I.e., just /.idea/ should work.
    – phd
    Nov 12 at 11:15










  • @torek Aha! This explains every behavior I didn't understand. And so, sadly, it isn't possible to accomplish what I want then.
    – Tomáš Kafka
    Nov 13 at 11:54










  • @Antwane Thanks, it's a hack, but it seems like the only possible solution.
    – Tomáš Kafka
    Nov 13 at 11:55















As an alternative, you could put !.idea/ rule in your personal project's .gitignore. That will cancel the ignore rule defined globally, and you will be able to commit your .idea directory
– Antwane
Nov 12 at 10:09





As an alternative, you could put !.idea/ rule in your personal project's .gitignore. That will cancel the ignore rule defined globally, and you will be able to commit your .idea directory
– Antwane
Nov 12 at 10:09





1




1




The global gitignore is treated as if it were in the root Git directory (the work-tree top level).
– torek
Nov 12 at 10:09




The global gitignore is treated as if it were in the root Git directory (the work-tree top level).
– torek
Nov 12 at 10:09












I.e., just /.idea/ should work.
– phd
Nov 12 at 11:15




I.e., just /.idea/ should work.
– phd
Nov 12 at 11:15












@torek Aha! This explains every behavior I didn't understand. And so, sadly, it isn't possible to accomplish what I want then.
– Tomáš Kafka
Nov 13 at 11:54




@torek Aha! This explains every behavior I didn't understand. And so, sadly, it isn't possible to accomplish what I want then.
– Tomáš Kafka
Nov 13 at 11:54












@Antwane Thanks, it's a hack, but it seems like the only possible solution.
– Tomáš Kafka
Nov 13 at 11:55




@Antwane Thanks, it's a hack, but it seems like the only possible solution.
– Tomáš Kafka
Nov 13 at 11:55












1 Answer
1






active

oldest

votes


















0














As per @torek in comments:




The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




So, there is no way to accomplish this, as there is no way to check the path of a whole project.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259795%2fglobal-gitignore-how-to-exclude-a-single-specific-folder%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    As per @torek in comments:




    The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




    So, there is no way to accomplish this, as there is no way to check the path of a whole project.






    share|improve this answer

























      0














      As per @torek in comments:




      The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




      So, there is no way to accomplish this, as there is no way to check the path of a whole project.






      share|improve this answer























        0












        0








        0






        As per @torek in comments:




        The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




        So, there is no way to accomplish this, as there is no way to check the path of a whole project.






        share|improve this answer












        As per @torek in comments:




        The global gitignore is treated as if it were in the root Git directory (the work-tree top level).




        So, there is no way to accomplish this, as there is no way to check the path of a whole project.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 11:57









        Tomáš Kafka

        2,46252942




        2,46252942



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259795%2fglobal-gitignore-how-to-exclude-a-single-specific-folder%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto