有没有办法只从远程Git仓库检索一个特定的提交而不在我的PC上克隆它?远程仓库的结构与我的结构完全相同,因此不会有任何冲突,但我不知道如何做到这一点,我不想克隆那个庞大的存储库.
我是git的新手,有什么办法吗?
使用Git 1.7.0中新的稀疏结账功能,是否可以像在SVN中一样获取子目录的内容?我找到了这个例子,但它保留了完整的目录结构.想象一下,我只想要'perl'目录的内容,而没有名为'perl'的实际目录.
- 编辑 -
例:
我的git存储库包含以下路径
repo/.git/
repo/perl/
repo/perl/script1.pl
repo/perl/script2.pl
repo/images/
repo/images/image1.jpg
repo/images/image2.jpg
repo/doc/
repo/doc/readme.txt
repo/doc/help.txt
Run Code Online (Sandbox Code Playgroud)
我想要的是能够从上面的存储库中生成这种布局:
repo/.git/
repo/script1.pl
repo/script2.pl
Run Code Online (Sandbox Code Playgroud)
然而,使用当前的稀疏结账功能,似乎只能获得
repo/.git/
repo/perl/script1.pl
repo/perl/script2.pl
Run Code Online (Sandbox Code Playgroud)
这不是我想要的.
该git clone --depth命令选项说
--depth <depth>
Create a shallow clone with a history truncated to the specified number of revisions.
A shallow repository has a number of limitations
(you cannot clone or fetch from it, nor push from nor into it),
but is adequate if you are only interested in the recent history of a large project with a long history,
and would want to send in fixes as patches.
Run Code Online (Sandbox Code Playgroud)
为什么浅克隆有这种限制?为什么它只是一个补丁工作流程?
对于某些项目工作流程,我需要将最新的提交从单个分支传递给编码器,然后让它们能够push(快进)开发到主服务器.这部分是为了安全,知识产权保护和回购规模,部分是为了减少大回购会给天真编码员带来的困惑.是否有允许这样的git工作流程?
更新:根据Karl Bielefeldt的回答,git checkout --orphan …
我想克隆Linux内核repo,但仅从3.0版本开始,因为内核repo非常庞大,如果我可以做一个浅层克隆,我的版本控制工具运行得更快.我的问题的核心是:我如何告诉git --depth参数的"n"值是什么?我希望这会奏效:
git clone http://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git --depth v3.0
谢谢.
我有一个git repo我想做一个浅拷贝,只拉一个分支.
这个SO问题说git clone默认拉动所有远程分支.我想做一个只有一个分支的浅表副本.
我这样做是为了部署到生产中.完整的结账超过400MB,但头部的git存档只有16MB.似乎克隆下拉所有分支的行为导致我的下载比必要的大得多.
我的程序可以通过ssh远程访问git存储库,有时需要获取有关特定git提交的信息(如提交消息).如何在没有存储库的本地克隆的情况下查询远程git存储库以获取此类信息?