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

前端 未结 10 816
南旧
南旧 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:17

    Small variation from Eric Burcham's answer. That answer adds \.git to end, this one doesn't.

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

    I use this command at the beginning of the day. It simply adds a few git commands to the above. For some reason, our git repository works best if one runs a fetch then pull, don't know why. And we have a lot of submodules for some reason. Anyway, put what you need in between the {}'s.

    push-location; Get-ChildItem . -Attributes Directory+Hidden -ErrorAction SilentlyContinue -Filter ".git" -Recurse | % { cd $_.parent.fullname; write-host '*************'; $(get-location).path; git fetch; git pull; git checkout .; git clean -f; git submodule update; git status; write-host '*************'; write-host ' '; }; pop-location
    

提交回复
热议问题