gitgithubgitignorepackage-managers

Reference multiple online gitignore templates in gitignore


For my global gitignore, I would like multiple up-to-date gitignore templates from https://github.com/github/gitignore for my OS / IDEs / languages / frameworks like macOS, Java, Android, and JetBrains.

There are some solutions here to concatenate locally:

Can I include other .gitignore file in a .gitignore file? (like #include in c-like languages)

gitignore loads other gitignores

but I'm wondering if there are more elegant solutions that simply concatenate the up-to-date templates from the specified urls.


Solution

  • git config --global core.excludesfile ~/.gitignore
    
    # concatenating URLs
    curl https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore > ~/.gitignore
    
    # alternative pre-concatenated .gitignore service
    curl -sL https://www.gitignore.io/api/c,c++ > ~/.gitignore
    

    Lines like this in my .bashrc file run every time I launch my shell and overwrite my global .gitignore file with the latest versions of the .gitignore's from that repository