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.
3 Answers
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

- 367
- 1
- 9
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.. :)

- 1,103
- 1
- 8
- 16
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

- 1
- 1