Git: how to find git repository directories

To find many git repository directories on your local system, we use the find command:

  find ~ -type d -name .git

Sample result:

  ~/foo/.git
  ~/bar/baz/.git
  ~/some/other/directory/.git

To use "find"

We use these find command options:

To learn more about find, search the net for: unix man page find

To chop the git repository: xargs dirname

To chop off the .git repository from the directory path, we use the xargs and dirname command:

  find ~ -type d -name .git | xargs -n 1 dirname

Sample result:

  ~/foo
  ~/bar/baz
  ~/some/other/directory

To learn more about dirname, search the net for: unix man page dirname

To learn more about xargs, search the net for: unix man page xargs



What's Next?

blog comments powered by Disqus