我想要
git clone
我在 GitHub 上的存储库的内容。当我 git clone
(git@github:me/name.git...) 我得到一个名为 name/
的文件夹,里面的名称是我的内容...我如何获取内容?
如果当前目录为空,您可以使用:
git clone [email protected]:me/name.git .
(请注意末尾的
.
来指定当前目录。)当然,这还会在当前文件夹中创建 .git
目录,而不仅仅是项目中的源代码。
这个可选的
[directory]
参数记录在 git clone
手册页中,它指出仅当现有目录为空时才允许克隆到该目录。
不幸的是,如果同一目录中已有其他不相关的目录,则此方法不起作用。寻找解决方案。错误消息为:“致命:目标路径 '.'已经存在...”。
这种情况的解决办法是:
git init
git remote add origin [email protected]:me/name.git
git pull origin master
即使您想要签出的目录中有其他目录,此食谱也有效。
我正在行使其 GDPR 权利来删除我的贡献
您可以将目标目录指定为
git clone
命令的第二个参数,因此您可以执行以下操作:
git clone <remote> .
这将直接将存储库克隆到当前本地目录中。
将 git repo 克隆到 current 和 empty 文件夹(无
git init
),如果您不使用 ssh:
git clone https://github.com/accountName/repoName.git .
我知道这个问题很旧,但请注意,如果存在与远程文件匹配的本地文件,
git pull
将中止,解决方案是在像这样拉动后进行重置:
git init
git remote add origin REMOTE_REPO_URL.git
git pull origin master
git reset --hard FETCH_HEAD
这位工人对我来说
git clone <repository> .