How can I view all the git repositories on my machine?

前端 未结 10 780
南旧
南旧 2020-11-29 21:00

Is there a way in which I can see all the git repositories that exist on my machine? Any command for that?

相关标签:
10条回答
  • 2020-11-29 21:26

    ORIGINAL ANSWER: This works pretty well from Windows Powershell:

    Get-ChildItem . -Attributes Directory+Hidden -ErrorAction SilentlyContinue -Include ".git" -Recurse
    

    EDIT #1: -Filter is twice as fast as -Include. Here is that solution:

    Get-ChildItem . -Attributes Directory+Hidden -ErrorAction SilentlyContinue -Filter ".git" -Recurse
    

    EDIT #2: Keith E. Truesdell mentioned sending the output to a file. See his comment for that solution. I prefer console output. But his comment got me thinking that I prefer just the full path, not the whole mess that is returned by default. If you want that just the full path, use the following:

    Get-ChildItem . -Attributes Directory+Hidden -ErrorAction SilentlyContinue -Filter ".git" -Recurse | % { Write-Host $_.FullName }
    

    FINAL NOTE: The above solutions only return Git repositories under the current directory. If you want ALL repositories on a drive, you should run the command once from the root of each drive.

    0 讨论(0)
  • 2020-11-29 21:27

    On Linux, try this command with root permission:

    find / | grep \\.git$
    

    this just searchs every files that end with .git ... you can do it with searching tools in Windows, Linux etc...

    0 讨论(0)
  • 2020-11-29 21:28

    If you are in Linux find / -name ".git", otherwise there is no way, they are standard directories, just use your OS file/folder find program to find .git named folders.

    0 讨论(0)
  • 2020-11-29 21:33

    For Linux:

    dir="/home/${USER}"
    dir_not="${dir}/miniconda3"
    find /home/aeug -type d -iname ".git" -o -path "${dir_not}" -prune | xargs -0 echo 
    
    0 讨论(0)
提交回复
热议问题