-2

I am trying to find a git repository on my VM running Ubuntu. I assume it has been created, but not sure. What is the best way to find out if any git repository is present? I have installed git.

Nash
  • 1,043
  • 2
  • 14
  • 33
  • Does this answer your question? [How can I view all the git repositories on my machine?](https://stackoverflow.com/questions/2020812/how-can-i-view-all-the-git-repositories-on-my-machine) – Aissaoui Ahmed Jan 30 '23 at 11:40

3 Answers3

4

If you would like to search your entire system for a git repo, then I would advise using find.

Every git repo has a .git folder, so by using find to search for them, you could return every directory that contains a .git folder.

$ find ~ -type d -name ".git" -print

This will output all folders that are git repositories within your user account.

Otherwise if you want to check if the directory you are in is already a git repo, you would simply run:

$ git status

It will return either

fatal: Not a git repository (or any of the parent directories): .git

or

On branch master
Ryen Nelsen
  • 367
  • 1
  • 9
0

On the topmost level directory of your repo, you can try:

 $ cd .git

If it is not failing, then certainly that is a git repository.

Every git repository has a .git hidden directory at its topmost level.

Hope it helps.. :)

Tarun Gaba
  • 1,103
  • 1
  • 8
  • 16
0

On the directory you assume that is a repository, try following command:

$ git status

If this directory contains a repository, it will show something like this:

On branch master
bonsagg
  • 1
  • 1