没有前导目录的Git稀疏签出 [英] Git sparse checkout without leading directories
问题描述
我了解如何在Git中配置稀疏签出,但是我想知道是否有可能消除领先的目录.例如,假设我有一个Git存储库,其文件夹结构如下:
I understand how to configure a sparse checkout in Git, but I was wondering if it's possible to eliminate the leading directories. For example, say I have a Git repository with a folder structure like so:
- folder1/foo
- folder2/foo/bar/stuff
- folder3/another/foo/bar/stuff2
我只想要stuff2
中的内容.对于这些目录的稀疏签出,.git/info/spare-checkout
文件如下所示:
And I only want the contents inside stuff2
. For sparse checkout of those directories, the .git/info/spare-checkout
file would look like this:
folder3/another/foo/bar/stuff2/
我的问题是在完成稀疏签出后,我不看不到目录根目录中的stuff2
或stuff2
的内容;我看到folder3
,然后看到所有导致stuff2
的子目录.
My problem is after I'm finished with the sparse checkout, I don't see stuff2
or the contents of stuff2
inside the root of my directory; I see folder3
and then all of the subdirectories leading up to stuff2
.
我猜这个问题的答案是Git无法实现,但我只是想确定一下.这是我遗漏的SVN的[strong> one (也是唯一)行为;能够运行svn co https://url.com/myrepo/folder3/another/foo/bar/stuff2 .
并将内容转储到当前目录中.
I'm guessing the answer to this question is that it's not possible with Git, but I just wanted to make sure. This is one (and only) behavior of SVN that I miss; the ability to run svn co https://url.com/myrepo/folder3/another/foo/bar/stuff2 .
and have the contents dumped into the current directory.
推荐答案
像git hub这样的工具可以直接查看给定的文件夹.但是在git中,一次只能在一个文件夹上操作是被禁止的,因为必须存在整个存储库才能执行新提交的哈希并为提交进行差异
Some tools like git hub have the ability to view a given folder directly. However to operate on only one folder at a time is forbidden in git as the whole repository must be present to perform the hash of the new commit and make the diff for the commit
这里也进行了讨论如何进行git-拉除一个文件夹之外的所有文件夹
这篇关于没有前导目录的Git稀疏签出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!