Is it better to use git grep than plain grep if we want to search in versioned source code?

后端 未结 5 1794
温柔的废话
温柔的废话 2021-01-31 02:03

In a git repository, is there any difference/benefit using git grep over good old grep?
An example would be?

5条回答
  •  无人及你
    2021-01-31 02:23

    git grep only searches in the tracked files in the repo.

    With grep you have to pass the list of files to search through and you would have filter out any untracked files yourself.

    So if you are searching for something that you know is in the repo, git grep saves you time as all you have to do is provide the pattern. It also is useful for not having to search through anything that is untracked in the repo.

提交回复
热议问题