2

I've got a git repository which is a total mess of branches, commits, and stashes.

What I want to do is to search and extract all files containing a given string.

The search should cover all previous versions of all files that ever existed in any shape or form in the repository, and should return the matching files (ideally, they would be extracted and copied to some given path).

Any suggestions? Thanks

ldmat
  • 935
  • 1
  • 6
  • 15

1 Answers1

3

Try this.

git grep <regexp> $(git rev-list --all)

More detailed info here: https://stackoverflow.com/a/2929502/1520297

Later on, when e.g copying files to desired location you could use cut program to extract filenames.

Community
  • 1
  • 1
Zajo
  • 362
  • 2
  • 14