Git sparse checkout without leading directories [duplicate]

别来无恙 提交于 2019-12-04 22:24:41

问题


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

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/

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.

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.


回答1:


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

It is also discussed here How to git-pull all but one folder



来源:https://stackoverflow.com/questions/35097530/git-sparse-checkout-without-leading-directories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!