Is there a way in which I can see all the git repositories that exist on my machine? Any command for that?
Is there a way in which I can see all the git repositories that exist on my machine? Any command for that?
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.
Git repositories all have HEAD, refs and objects entries.
on GNU/anything,
find -name HEAD -execdir test -e refs -a -e objects \; -printf %h\\n
Just checking for .git will miss many bare repos and submodules.
To go full-paranoid on the checking you can ask git to do all its own checks before printing,
find -name HEAD -execdir test -e refs -a -e objects \; \
-execdir sh -ec 'GIT_DIR=$PWD git rev-parse --absolute-git-dir 2>&-' \;
(edit: I thought the .git/config file was necessary, turns out it's not, so the absolute minimum git init newrepo is
mkdir -p newrepo/.git/{objects,refs}
echo ref: refs/heads/master >newrepo/.git/HEAD
)
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...
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