7

Is there some tool or webservice that takes a .gitignore file, tests the rules somehow and notifies one about duplicate rules (i.e. whose matches overlap)?

I have a long-running Git-repository that was initialised with several of GitHub's default .gitignore templates, which were amended manually over the course of several months. After removing some obvious duplicate ignore rules such as test-A.md and test-* manually I started wondering.

So far, I found methods to clean a text of duplicate phrases, but nothing that could actively evaluate the ignore rules. An answer may be useful for Syncthing and BitTorrent Sync users trying to clean up convoluted .syncignore rules. Thank you!

2 Answers 2

2

There is no automatic tool available as per my knowledge. But you can make use of the git-check-ignore for each rule through the command line.

Example:

git check-ignore -v filename

From the documentation

For each pathname given via the command-line or from a file via --stdin, check whether the file is excluded by .gitignore (or other input files to the exclude mechanism) and output the path if it is excluded.

By default, tracked files are not shown at all since they are not subject to exclude rules; but see ‘--no-index’.

0

you can use global .gitignore when you declare it in your .gitconfig as following.

[core]
   excludesfile = /Users/your_user_name/.gitignore_global

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.