Repository navigation
Replies: 2 comments 1 reply
|
Yeah, this works. The trick is that ripgrep reads
Then:
One rule worth knowing, because it trips people up: you can't re-include a file whose parent directory is ignored. That's git semantics that ripgrep follows deliberately, not a bug. So (Has to be |
|
--no-ignore is the key here. ripgrep's command-line globs take precedence over ignore rules, but a positive glob (like What you actually want is to disable all ignore rules, then re-exclude only the directories you don't want. This single command reproduces your desired output exactly: rg --files --hidden --no-ignore -g '!.git/' -g '!/node_modules/' Breaking it down:
The caveat: --no-ignore disables all ignore files, so anything else your .gitignore was excluding (e.g. dist/, build/) will come back too. Add a matching -g '!...' for each one you want to keep excluded. If you'd rather keep your existing .gitignore semantics for everything except .env*, an alternative is a .rgignore file - ripgrep treats it like .gitignore but it isn't disabled by --no-ignore-vcs: then: rg --files --hidden --no-ignore-vcs I verified both commands against your exact example layout and they produce the 12-file output you listed. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I want to list out all useful files in the repository I'm working in (think input to a fuzzy finder).
Here's an example file layout to work with:
With a `.gitignore` that looks like:
Desired output is:
What I tried
Let's start with:
Output:
Files that I still want are
.prettierrcand all files beginning with.envregardless of if they're in the.gitignore. Let's try with--hiddento at least get.prettierrc:Output:
Doh, now all of
.git/*is included. Let's try to glob that away:Output:
Great. Back on track. Now to try to show
.env*, try with a glob again:Output:
Now that's included all the
.env*files I wanted but excluded everything else.The following I think this is the right output but it's not very efficient and I would ideally like it as one command so it can avoid using a shell:
All reactions