Question

I have a file name - for example "MapControl.ascx"

The project is complex in tree structure. I'd like to perform simple search in the file tree WITHOUT the need to checkout.

I could just checkout that commit to my working dir and use simple Windows CTRL+F ... but I'm a lazy programmer and I believe there must be a better way.

For example: git magic_search_file_in_commit "MapControl.ascx" "commit_sha1_hash"

would output a list like this:

  • /folderA/folderB/MapControl.ascx
  • /anotherfolder/MapControl.ascx
  • /yetanotherfolder/folder/folder/MapControl.ascx

Any or all of these paths might have been deleted in future commits but that should not matter, the files existed in the commit I want.

How would I do that in GIT? Is that even possible?

Was it helpful?

Solution

You could do this

git ls-tree --name-only -r <commit-hash> | grep "MapControl.ascx"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top