繁体   English   中英

如何在没有项目名称的情况下指定目标目录的 git clone ?

[英]How to git clone with specifying the destination directory without its project name?

我使用 macOS 和 Ubuntu。 我想将某个项目https://github.com/Project/project.git git 克隆到特定目录$HOME/git 我看到了这个页面: 如何将 Git 存储库克隆到特定文件夹中? ,但它需要明确指定其项目名称,如: git clone https://github.com/Project/project.git $HOME/git/project 如何在不指定项目名称的情况下 git clone 它们?

[Add1] 如果我 git clone 像: git clone https://github.com/Project/project.git $HOME/git那么我遇到了fatal: destination path '/home/paalon/git' already exists and is not an empty directory. [Add2] 我想在$HOME/git目录下克隆git 管理的项目。 我想设置状态ls $HOME/git显示像project1/ project2/ project3/

分为2个命令:

cd $HOME/git
git clone https://github.com/Project/project.git

这样,您只需将项目命名一次。

如何将Git存储库克隆到特定文件夹中?

可以通过以下方式使用git clone命令:

 git clone <url> <destination>

致命:目标路径/home/paalon/git已经存在且不是空目录。

这是因为您已经拥有给定名称/home/paalon/git文件夹。
删除“旧文件夹”并再次克隆,这次添加克隆命令所需的路径

我认为这不是正确的。 您可以克隆提供任何目录作为目标。 它不必与项目名称匹配:

$ git clone https://github.com/eantoranz/bwv blahblah
Cloning into 'blahblah'...
remote: Enumerating objects: 221, done.
remote: Total 221 (delta 0), reused 0 (delta 0), pack-reused 221
Receiving objects: 100% (221/221), 62.45 KiB | 480.00 KiB/s, done.
Resolving deltas: 100% (150/150), done.`1
git -C $HOME/git clone https://github.com/someorg/Boostnote.git

将创建$HOME/git/Boostnote

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM