Skip to content

ripgrep not respecting global .gitignore #2392

@Avishayy

Description

@Avishayy

What version of ripgrep are you using?

ripgrep 13.0.0
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)

How did you install ripgrep?

brew

What operating system are you using ripgrep on?

macOS Ventura 13.1

Describe your bug.

I have some local backup files in my dev repo and I'd like to ignore them from all rg functionalities. Since they exist on my local machine I don't add them to the repo tracked .gitignore, so I configured a global gitignore but it seems to not work. #9 seems to create support for it, but it's quite old already so perhaps it's now broken.

What are the steps to reproduce the behavior?

$ git config core.excludesFile
~/.gitignore

$ cat ~/.gitignore
*.sql

$ rg --files | rg backup
backup
backup_21_07_2022.sql
backup_11-12-22.sql
db_backup.sql

$ git add db_backup.sql
The following paths are ignored by one of your .gitignore files:
db_backup.sql
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"

$ echo "*.sql" >> .gitignore

$ rg --files | rg backup
backup

You can see that git refuses to add the file since it is ignored by the global .gitignore and then that ripgrep would only respect it if is present in the working directory.

What is the actual behavior?

Patterns from global .gitignore are ignored by ripgrep

What is the expected behavior?

Patterns from global .gitignore are respected by ripgrep

What do you think ripgrep should have done?

Ignore the patterns present in the global .gitignore

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug.rollupA PR that has been merged with many others in a rollup.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions