命令git clonegit@github.com:whatever创建一个名为whatever的目录,其中包含Git存储库:
./
whatever/
.git
我希望将Git存储库的内容克隆到我的当前目录中。/而是:
./
.git
命令git clonegit@github.com:whatever创建一个名为whatever的目录,其中包含Git存储库:
./
whatever/
.git
我希望将Git存储库的内容克隆到我的当前目录中。/而是:
./
.git
当前回答
如果要将其签入当前目录,请确保删除.git存储库。
rm-rf.git然后是git克隆https://github.com/symfony/symfony-sandbox.git
其他回答
For Windows user
1> Open command prompt.
2> Change the directory to destination folder (Where you want to store your project in local machine.)
3> Now go to project setting online(From where you want to clone)
4> Click on clone, and copy the clone command.
5> Now enter the same on cmd .
It will start cloning saving on the selected folder you given .
您可以使用以下git命令使用自定义目录名进行克隆
git clone <git_repo_url> <your_custom_directory_name>
注意:您不需要创建自定义目录,因为它会自动创建
要将git存储库克隆到特定文件夹中,可以使用-C<path>参数,例如。
git -C /httpdocs clone git@github.com:whatever
尽管它仍然会在其上创建一个任意文件夹,但要将存储库的内容克隆到当前目录中,请使用以下语法:
cd /httpdocs
git clone git@github.com:whatever .
请注意,仅当目录为空时,才允许克隆到现有目录中。
由于要克隆到可供公众访问的文件夹中,请考虑使用--separate Git-dir=<Git-dir>或在web服务器配置中排除.Git文件夹(例如在.htaccess文件中),将Git存储库与工作树分离。
选项A:
git clone git@github.com:whatever folder-name
Ergo,在这里使用:
git clone git@github.com:whatever .
选项B:
也移动.git文件夹。请注意,.git文件夹在大多数图形文件浏览器中都是隐藏的,所以一定要显示隐藏的文件。
mv /where/it/is/right/now/* /where/I/want/it/
mv /where/it/is/right/now/.* /where/I/want/it/
第一行获取所有普通文件,第二行获取点文件。也可以通过启用dotglob(即shopt-s dotglob)在一行中完成,但如果你问这个答案所回答的问题,这可能是一个糟糕的解决方案。
更好:
将工作副本保存在其他地方,并创建一个符号链接。这样地:
ln -s /where/it/is/right/now /the/path/I/want/to/use
对于您的情况,这可能是:
ln -sfn /opt/projectA/prod/public /httpdocs/public
如果您需要,可以很容易地将其更改为测试,即:
ln -sfn /opt/projectA/test/public /httpdocs/public
而无需四处移动文件。添加了-fn,以防有人复制这些行(-f是强制的,-n避免与现有和非现有链接进行一些经常不需要的交互)。
如果你只是想让它发挥作用,使用选项A,如果其他人要看你做了什么,使用选项C。
虽然上面的所有答案都很好,但我想提出一种新的方法,而不是在公共html目录中使用符号链接方法,正如公认答案中提出的BEST。您需要访问服务器虚拟主机配置。
它是关于配置直接指向存储库目录的web服务器的虚拟主机。在Apache中,您可以这样做:
DocumentRoot/var/www/html/website/your git repo
以下是虚拟主机文件的示例:
<VirtualHost *:443>
ServerName example.com
DocumentRoot /path/to/your-git-repo
...
...
...
...
</VirtualHost>