Acknowledgment: This is meant to be the Windows equivalent of Anders Janmyr’s excellent post on the subject of finding stuff with Git. Essentially, I’m translating some of Anders’ examples to Powershell and providing explanations for things that many Windows devs might not be familiar with.
This is the first in a series of posts providing a set of recipes for locating sundry and diverse thingies in a Git repository.
Finding files by name
Let’s say that you want locate all the files in a git repository that contain ‘monkey’ in the file name. (Finding monkeys is a very common task.)
# find all files whose name matches 'monkey'
PS:\> git ls-files | Select-String monkey
This pipes the output of
git ls-files into the Powershell cmdlet
Select-String which filters the output line-by-line. To better understand what this means, run just
Of course, you can also pass a regular expression to
Select-String (that is, if you hate yourself.)
Comment on this post at dev.bennage.com
Next, searching for files with specific content.
01-30-2012 12:01 PM