[英]How to clone only a folder from a git submodule?
I'm trying to get just a folder from an external github repo to use in my project. 我正在尝试从外部github仓库获取一个文件夹,以便在我的项目中使用。
I want my project setup to be like this: 我希望我的项目设置如下:
-my_project
-submodule
-code.py
-MY_README
-.git
And I have the remote repo named some-submodule with following structure: 我有一个名为some-submodule的远程repo,结构如下:
-submodule
-code.py
-README
-.gitignore
So I just want the submodule folder added to my project. 所以我只想将子模块文件夹添加到我的项目中。
But I end up with this after 但是之后我最终得到了这个
git submodule add http://github.com/user/submodule.git submodule
-my_project
-submodule
-submodule
-code.py
-README
-.gitignore
-MY_README
-.gitignore
I am new to git so I really don't know if it possible using just git. 我是git的新手所以我真的不知道是否可以使用git。 If it is of some help I'm using msysgit on windows.
如果它有一些帮助我在Windows上使用msysgit。
So, is there anyway that I can get a clean submodule folder in my project from a public repo? 那么,无论如何我可以从公共仓库中获得一个干净的子模块文件夹吗?
If you're curious of exactly what I'm trying to do I'm trying to take directly from their repos these django plugins 1 2 to add them to my project. 如果你对我正在尝试做的事情感到好奇,我试图直接从他们的repos这些django插件1 2中将它们添加到我的项目中。
What you want to do is not feasible because you cannot clone a part of a repository. 您想要做的是不可行的,因为您无法克隆存储库的一部分。
See details in duplicate How to change a git submodule to point to a subfolder? 一式两份详细信息如何更改git子模块以指向子文件夹?
If you: 如果你:
git submodule add http://github.com/user/submodule.git
directly under my_project
, you should end up with the desired organization of directories. 直接在
my_project
下,您应该最终得到所需的目录组织。
From git submodule add
man page : 从
git submodule add
手册页 :
The optional argument
<path>
is the relative location for the cloned submodule to exist in the superproject.可选参数
<path>
是克隆子模块在超级项目中存在的相对位置。
If<path>
is not given, the "humanish" part of the source repository is used ("repo" for "/path/to/repo.git
" and "foo
" for "host.xz:foo/.git
").如果
<path>
没有给出,源库的“humanish”部分被使用(“回购”为“/path/to/repo.git
”和“foo
”为“host.xz:foo/.git
”) 。
just 只是
git submodule update --init --recursive
in the root-directory of your project and it should do what you want 在项目的根目录中,它应该做你想要的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.