the_silver_searcher icon indicating copy to clipboard operation
the_silver_searcher copied to clipboard

.gitignore directory matching discrepancies

Open jtuckerk opened this issue 2 years ago • 1 comments

I am seeing that git and ag have different ignore logic.

as a minimal example within a repo structured like so:

a_repo
├── .gitignore
├── config_dir
│   └── personal_config.txt
└── sub_dir
    └── config_dir
        └── code_to_track.py

We want to ignore all files in a_repo/config_dir by having a .gitignore file like:

config_dir/

git works as expected ignoring the personal_config.txt, while tracking changes in code_to_track.py, however ag incorrectly decides to ignore any directory like config_dir so I am not receiving results from code_to_track.py

Ag is amazing and I'll try to contribute a fix if I can figure it out!

jtuckerk avatar May 02 '22 09:05 jtuckerk

This .gitignore excludes config_dir/ on all levels. And code_to_track.py is only tracked if it is explicitly added.

Use /config_dir/ to exclude the first one only.

https://www.atlassian.com/git/tutorials/saving-changes/gitignore#git-ignore-patterns

No5251 avatar May 17 '22 06:05 No5251