Git - 在 Ubuntu 上找到 git 存储库

Git - finding a git repository on Ubuntu

我正在尝试在我的 VM 运行 Ubuntu 上找到 git 存储库。我假设它已经创建,但不确定。查明是否存在任何 git 存储库的最佳方法是什么?我已经安装了 git.

在你的 repo 的最顶层目录,你可以尝试:

 $ cd .git

如果没有失败,那么肯定是 git 存储库。

每个 git 存储库的最顶层都有一个 .git 隐藏目录。

希望对您有所帮助..:)

如果您想在整个系统中搜索 git 存储库,那么我建议您使用 find.

每个 git 存储库都有一个 .git 文件夹,因此通过使用 find 搜索它们,您可以 return 每个目录包含 .git 文件夹。

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

这将输出您用户帐户中 git 个存储库的所有文件夹。

否则,如果您想检查您所在的目录是否已经是一个 git 存储库,您只需 运行:

$ git status

它将 return 或者

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

On branch master

在您认为是存储库的目录上,尝试以下命令:

$ git status

如果此目录包含存储库,它将显示如下内容:

On branch master