Can I use Git to search for matching filenames in a repository?

后端 未结 6 1324
盖世英雄少女心
盖世英雄少女心 2020-12-04 12:58

Just say I have a file: \"HelloWorld.pm\" in multiple subdirectories within a Git repository.

I would like to issue a command to find the full paths of all the files

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 14:01

    git ls-files will give you a listing of all files in current state of the repository (the cache or index). You can pass a pattern in to get files matching that pattern.

    git ls-files HelloWorld.pm '**/HelloWorld.pm'
    

    If you would like to find a set of files and grep through their contents, you can do that with git grep:

    git grep some-string -- HelloWorld.pm '**/HelloWorld.pm'
    

提交回复
热议问题