Created
February 6, 2025 16:30
-
-
Save mikebridge/bdcc996b3ac807df67aaece8f0c70daf to your computer and use it in GitHub Desktop.
Find a file by name among many git branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
FILE_NAME_PATTERN="index.ts" | |
git branch --format="%(refname:short)" | xargs -I {} sh -c 'git ls-tree -r --name-only "{}" | grep -q "${FILE_NAME_PATTERN}" && echo "File exists in {}"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment