是否有可能让Git知道现有的.gitmodules文件? [英] Is it possible to make Git aware of an existing .gitmodules file?
问题描述
我添加了一个子模块:
$ p $ g $子模块添加git://github.com/chneukirchen/rack.git rack
文件 .gitmodules
的创建方式如下所示:
[submodulerack]
path = rack
url = git://github.com/ chneukirchen / rack.git
当然Git知道它:
git submodule status
30fb044db6ba5ea874ebc44a43bbd80a42676405 rack(1.3.0-64-g30fb044)
我手工添加了一个子模块,例如添加到该文件中:
[submoduleredcloth]
path = plugins / redcloth
url = git://github.com/jgarber/redcloth.git
我重复了前面的命令:
git submodule init
子模块'rack'()注册路径'rack'
git子模块更新
(无输出)
git子模块状态
30fb044db6ba5ea 874ebc44a43bbd80a42676405 rack(1.3.0-64-g30fb044)
所以,据我所知,手动添加被忽略。有没有办法让Git知道在.gitmodules文件中手动添加的行?
注意:我也尝试将手动添加到 .git / config
文件,这也不起作用。
你需要运行
git submodule update --init --recursive
更新:
子模块add命令实际上克隆了整个回购并将sha1添加到索引。
这可能是新的行为,与以前版本的git相比,克隆没有立即完成。
如果您在索引中没有指向某个特定提交的条目,则git子模块更新将拒绝执行任何操作。这似乎是新的行为。
希望这有助于。
I added a submodule:
git submodule add git://github.com/chneukirchen/rack.git rack
A file .gitmodules
was created like:
[submodule "rack"]
path = rack
url = git://github.com/chneukirchen/rack.git
And of course Git knows about it:
git submodule status
30fb044db6ba5ea874ebc44a43bbd80a42676405 rack (1.3.0-64-g30fb044)
I added a submodule by hand, for example, adding to that file:
[submodule "redcloth"]
path = plugins/redcloth
url = git://github.com/jgarber/redcloth.git
And I repeated the previous command:
git submodule init
Submodule 'rack' () registered for path 'rack'
git submodule update
(no output)
git submodule status
30fb044db6ba5ea874ebc44a43bbd80a42676405 rack (1.3.0-64-g30fb044)
So, as far I can see, what I added by hand is ignored. Is there some way to make Git aware of the lines added by hand in the .gitmodules file?
Note: I've also tried to add the lines by hand to the .git/config
file and that didn't work either.
You need to run
git submodule update --init --recursive
UPDATE:
the submodule add command actually clones the entire repo and adds the sha1 to the index.
This may be new behaviour as compared to previous versions of git, the clone was not done immediately.
If you don't have an entry in the index pointing the module to a particular commit, git submodule update refuses to do anything. This seems to be new behaviour.
Hope this helps.
这篇关于是否有可能让Git知道现有的.gitmodules文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!