命令git clonegit@github.com:whatever创建一个名为whatever的目录,其中包含Git存储库:

./
    whatever/
        .git

我希望将Git存储库的内容克隆到我的当前目录中。/而是:

./
    .git

当前回答

虽然上面的所有答案都很好,但我想提出一种新的方法,而不是在公共html目录中使用符号链接方法,正如公认答案中提出的BEST。您需要访问服务器虚拟主机配置。

它是关于配置直接指向存储库目录的web服务器的虚拟主机。在Apache中,您可以这样做:

DocumentRoot/var/www/html/website/your git repo

以下是虚拟主机文件的示例:

<VirtualHost *:443>
    ServerName example.com

    DocumentRoot /path/to/your-git-repo
    ...
    ...
    ...
    ...
</VirtualHost>

其他回答

进入文件夹。。如果文件夹为空,则:

git clone git@github.com:whatever .

else

git init
git remote add origin PATH/TO/REPO
git fetch
git checkout -t origin/master

我想很多人都想问这个问题的例子就是这个。如果您位于git存储库内容转储到的目录中,请运行:

git clone git@github.com:whatever .

结尾处的“.”将当前文件夹指定为签出文件夹。

要克隆到当前工作目录:

git clone https://github.com/link.git

要克隆到另一个目录:

git clone https://github.com/link.git ./Folder1/Folder2

希望它有帮助:)

如果使用ssh进行git克隆,可以使用以下命令。

git-C路径克隆git@github.com:路径_to_epo.git

如:git-C/home/ubuntu/clonegit@github.com:kennetritz/requests.git将请求的git存储库拉到/home/ubuntu/path。

转到要克隆回购的目录。(不要在该目录中运行gitinit命令)只需运行命令,git clone<git repo url>。

示例:git clonehttps://github.com/Rashmi-Wijesekara/portfolio.git .