Skip to content
Myr

Merge pull request #1540 from tmccombs/revert-git-ignore

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Stop ignore .git folders by default

authored by Thayne McCombs · committed by GitHub · parents 8eb0479, e10a4ea · Browse files · 6 files+40 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+40 added−13 removed

  • tests:+8 added−1 removed
  • other:+32 added−12 removed

6 files+40 added−13 removed

modified:doc/fd.1+23 added-5 removed
31 unmodified lines
32.P33By default34.B fd35will exclude hidden files and directories, as well as any files that match gitignore rules36or ignore rules in .ignore or .fdignore files. For convenenience, '.git' is treated as if it37was always included in gitignore rules. These files can be included with options such as38'\-\-hidden' and '\-\-no\-ignore'.36or ignore rules in .ignore or .fdignore files.37.SH OPTIONS38.TP39.B \-H, \-\-hidden40Include hidden files and directories in the search results41(default: hidden files and directories are skipped). The flag can be overridden with '--no-hidden'.42.IP45Ignored files and .git/ are still excluded unless \-\-no\-ignore or \-\-no\-ignore\-vcs43Ignored files are still excluded unless \-\-no\-ignore or \-\-no\-ignore\-vcs44is also used.45.TP46.B \-I, \-\-no\-ignore47Show search results from files and directories that would otherwise be ignored by
28 unmodified lines
76and the global gitignore configuration77.RI ( core.excludesFile78git setting, which defaults to79.IR $HOME/.config/git/ignore ).82The pattern ".git/" is automatically added to the list of VCS ignore rules.80The flag can be overridden with '--ignore-vcs'.81.TP82.B \-\-no\-require\-git83Do not require a git repository to respect gitignores. By default, fd will only
406 unmodified lines
490is set, use491.IR $XDG_CONFIG_HOME/fd/ignore .492Otherwise, use493.IR $HOME/.config/fd/ignore .494.SH FILES495.TP496.B .fdignore497This file works similarly to a .gitignore file anywhere in the searched tree and specifies patterns498that should be excluded from the search. However, this file is specific to fd, and will be used even499if the --no-ignore-vcs option is used.500.TP501.B $XDG_CONFIG_HOME/fd/ignore502Global ignore file. Unless ignore mode is turned off (such as with --no-ignore)503ignore entries in this file will be ignored, as if it was an .fdignore file in the504current directory.505.SH EXAMPLES506.TP507.RI "Find files and directories that match the pattern '" needle "':"508$ fd needle
5 unmodified lines
514$ fd -e py515.TP516.RI "Open all search results with vim:"517$ fd pattern -X vim518.SH Tips and Tricks519.IP \[bu]520If you add ".git/" to your global ignore file ($XDG_CONFIG_HOME/fd/ignore), then521".git" folders will be ignored by default, even when the --hidden option is used.522.IP \[bu]523You can use a shell alias or a wrapper script in order to pass desired flags to fd524by default. For example if you do not like the default behavior of respecting gitignore,525you can use526`alias fd="/usr/bin/fd --no-ignore-vcs"`527in your .bashrc to create an alias for fd that doesn't ignore git files by default.528.SH BUGS529Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues530.SH SEE ALSO531.BR find (1)
modified:src/cli.rs+2 added-3 removed
47 unmodified lines
48 #[arg(long, overrides_with = "hidden", hide = true, action = ArgAction::SetTrue)]49 no_hidden: (),5051 /// Show search results from files and directories that would otherwise be52 /// ignored by '.gitignore', '.ignore', '.fdignore', the global ignore file,53 /// or the default rule that excludes .git/.52 /// ignored by '.gitignore', '.ignore', '.fdignore', or the global ignore file,53 /// The flag can be overridden with --ignore.54 #[arg(55 long,56 short = 'I',
5 unmodified lines
62 /// Overrides --no-ignore63 #[arg(long, overrides_with = "no_ignore", hide = true, action = ArgAction::SetTrue)]64 ignore: (),6567 ///Show search results from '.git/' folders and files and directories that66 ///Show search results from files and directories that67 ///would otherwise be ignored by '.gitignore' files.68 ///The flag can be overridden with --ignore-vcs.69 #[arg(70 long,
803 unmodified lines
modified:src/walk.rs-4 removed
332 unmodified lines
333 .add(pattern)334 .map_err(|e| anyhow!("Malformed exclude pattern: {}", e))?;335 }336337 if config.read_vcsignore {338 builder.add("!.git/").expect("Invalid exclude pattern");339 }340337 builder338 .build()339 .map_err(|_| anyhow!("Mismatch in exclude patterns"))340 }
328 unmodified lines
modified:tests/tests.rs+8 added-1 removed
2571 unmodified lines
2572 "nested/dir/.git/foo2",2573 ],2574 );25752576 te.assert_output(&["--hidden", "foo"], "");2576 te.assert_output(2577 &["--hidden", "foo"],2578 ".git/one/foo.a2579 .git/.foo2580 .git/a.foo2581 other_dir/.git/foo12582 nested/dir/.git/foo2",2583 );2584 te.assert_output(&["--no-ignore", "foo"], "");2585 te.assert_output(2586 &["--hidden", "--no-ignore", "foo"],2587 ".git/one/foo.a
14 unmodified lines
modified:CHANGELOG.md+4 added
2 unmodified lines
3## Features45- Add `dir` as an alias to `directory` when using `-t` \ `--type`, see #1460 and #1464 (@Ato2207).6- Add support for @%s date format in time filters similar to GNU date (seconds since Unix epoch for --older/--newer), see #1493 (@nabellows)7- Breaking: No longer automatically ignore `.git` when using `--hidden` with vcs ignore enabled. This reverts the change in v9.0.0. While this feature8 was often useful, it also broke some existing workflows, and there wasn't a good way to opt out of it. And there isn't really a good way for us to add9 a way to opt out of it. And you can easily get similar behavior by adding `.git/` to your global fdignore file.10 See #1457.1112## Bugfixes1314- Respect NO_COLOR environment variable with `--list-details` option. (#1455)
740 unmodified lines
modified:README.md+3 added
280 unmodified lines
281If you want `fd` to ignore these patterns globally, you can put them in `fd`'s global ignore file.282This is usually located in `~/.config/fd/ignore` in macOS or Linux, and `%APPDATA%\fd\ignore` in283Windows.284285You may wish to include `.git/` in your `fd/ignore` file so that `.git` directories, and their contents286are not included in output if you use the `--hidden` option.287288### Deleting files289290You can use `fd` to remove all files and directories that are matched by your search pattern.291If you only want to remove files, you can use the `--exec-batch`/`-X` option to call `rm`. For
425 unmodified lines