如何克隆本地存储库

如何克隆本地存储库

我的机器上有两个彼此相邻的文件夹。

  • /Documents/Learning/Project1
  • /Documents/Learning/Test for git

Project1有一个本地存储库,其中包含一个提交,我想将其复制到另一个文件夹。我正在运行以下命令:

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1 .
fatal: repository '/Documents/Learning/Project1' does not exist

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1.git .
fatal: repository '/Documents/Learning/Project1' does not exist

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1.git .
fatal: repository '/Documents/Learning/Project1' does not exist

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1/.git .
fatal: repository '/Documents/Learning/Project1' does not exist

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1 .
fatal: repository '/Documents/Learning/Project1' does not exist

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1 .
fatal: repository '/Documents/Learning/Project1' does not exist

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1.git .
fatal: repository '/Documents/Learning/Project1' does not exist

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1/git .
fatal: repository '/Documents/Learning/Project1' does not exist

/Documents/Learning/Test for git$ git clone /Documents/Learning/Project1/.git .
fatal: repository '/Documents/Learning/Project1' does not exist

但我一直收到一条错误消息,说存储库不存在,我遗漏了什么?

答案1

您的存储库不在 中/Documents/Learning/Project1。它在 中/home/<your username>/Documents/Learning/Project1。您也可以使用快捷方式~/Documents/Learning/Project1

请注意,您不能将 git clone 到现有(非空)目录中,因此您应该删除~/Documents/Learning/Test for git,并且您的命令应该是(假设你当前的工作目录是~/Documents/Learning/):

$ git clone ~/Documents/Learning/Project1/ ./Test\ for\ git/

相关内容