Is there any way to list up git repositories in terminal?

To list all the git repositories you have on your system you can run the following command in a bash shell terminal (at the command line) and find them.

find / -name .git -type d -exec dirname {} \;

I found this more accurate than the find command and much faster. I'm sure it can be improved but it's a good start. Obviously your file database will need to be up-to-date before running this command. On linux systems you can do this by running 'updatedb'.

locate -br '\.git$' | rev | cut -c 6- | rev

lsgit is a script that does this. It's essentially a wrapper around locate -br '^HEAD$'.

If there are multiple clones of the same repo on the local machine, it will indicate that those repos are related.

Tags:

Terminal

Git