Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a 'git find'?

Tags:

git

Is there a git find analogue of git grep, i.e., something that will find a filename by pattern in the tree? I've gone through a lot of git documentation and not found this, but I'm having a hard time believing it doesn't exist somewhere.

like image 292
Martin DeMello Avatar asked Apr 14 '10 14:04

Martin DeMello


People also ask

How do I search text in git?

Git ships with a command called grep that allows you to easily search through any committed tree, the working directory, or even the index for a string or regular expression.

How do I find my git?

You typically obtain a Git repository in one of two ways: You can take a local directory that is currently not under version control, and turn it into a Git repository, or. You can clone an existing Git repository from elsewhere.

What files are searchable by git grep?

`git grep` command is used to search in the checkout branch and local files. But if the user is searching the content in one branch, but the content is stored in another branch of the repository, then he/she will not get the searching output.

How can we locate a particular git commit?

Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.


2 Answers

You can list all files in a tree object using git ls-tree -r --name-only --full-tree <treeish>. Pipe this through a regular grep to find what you're looking for.

like image 143
Geoff Reedy Avatar answered Oct 18 '22 02:10

Geoff Reedy


Try git-ls-tree and run the output through grep(1)

like image 36
Aaron Digulla Avatar answered Oct 18 '22 00:10

Aaron Digulla