how can I add git submodule into git repo as normal directory?

六眼飞鱼酱① 提交于 2019-12-03 08:06:51
kan

Seems you cannot do that. The name .git is hard-coded in the source code: https://github.com/git/git/blob/fe9122a35213827348c521a16ffd0cf2652c4ac5/dir.c#L1260

Probably one way is to make a script which renames .git to something else and back before and after adding it into repo like

In working directory under scripts

mv .git hidden-git

In Dockerfile

RUN mv $JENKINS_HOME/scriptler/scripts/hidden-git     
$JENKINS_HOME/scriptler/scripts/.git

Alternatively, probably it's possible to pass GIT_DIR environment variable into the plugin, so it could use another name.

VonC
git add sub
git commit -m "add sub directory"

I want to treat them as one git repo and push them remotely, but now the files under sub directory can not be included ?

They are not included because test sees repo sub as nested git repo, and records only its gitlink, or SHA1, and not its url as it would have if sub had been added as a submodule.

You would need to push sub to a remote url first, and then add it as submodule for test to see sub files.

 cd test
 git submodule add -- /url/to/sub

Or you would need to use a subtree

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