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

./
    whatever/
        .git

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

./
    .git

当前回答

由于某些原因,这种语法并不突出:

git clone repo url[文件夹]

这里,文件夹是指向本地文件夹(将是本地存储库)的可选路径。

Git克隆还会将代码从远程存储库拉入本地存储库。事实上,这是真的:

git clone repo-url  =  git init + git remote add origin repo-url + git pull

其他回答

如果使用github-cli,则可以使用以下命令:

gh repo clone <repository> [<directory>] [-- <gitflags>...]

例如,您可以运行以下命令:

gh repo clone repository-name-on-github my-local-folder

克隆:

git clone git@jittre.unfuddle.com:jittre/name.git

克隆“特定分支”:

git clone -b [branch-name] git@jittre.unfuddle.com:jittre/name.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存储库。

rm-rf.git然后是git克隆https://github.com/symfony/symfony-sandbox.git

您可以使用以下git命令使用自定义目录名进行克隆

git clone <git_repo_url> <your_custom_directory_name>

注意:您不需要创建自定义目录,因为它会自动创建