简体   繁体   中英

Find a specific folder in all remote and local GIT branches

I have few hundreds of remote and local branches. I wonder whether there is a command to help me find a folder with a specific name in all branches.

My git version is 1.8.3.1. I also have smartgit installed if it matters.

Thanks in advance.

The following command will output all refs (local and remotes) that point to a commit which contains the path specified in the variable SEARCH_PATH

SEARCH_PATH="somePath"

git for-each-ref --format="%(refname)" refs/heads refs/remotes | 
   while read ref
      do 
         if [[ `git ls-tree -r --name-only $ref` =~ "$SEARCH_PATH" ]] ; then                 
           echo $ref; 
         fi
   done

您可以运行以下命令列出所需的文件夹/文件

for line in `git for-each-ref --format="%(refname)" refs/heads`; do git ls-tree -r $line | grep 'file_regex' done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM