Skip to content

Instantly share code, notes, and snippets.

@lanrion
Last active August 2, 2020 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanrion/3384bef6989a6196bdc4 to your computer and use it in GitHub Desktop.
Save lanrion/3384bef6989a6196bdc4 to your computer and use it in GitHub Desktop.
git submodule 的使用

git submodule 的使用

更新submodule的代码

  • 进入主项目,git pull
  • git submodule update

提交submodule的代码

  • 切换到submodule master分支,add, commit, push
  • 进入主项目,提交主项目引用submodule的commit id
git add -u
git commit -m "update xxx to to lastest commit id"
git push

note

在主项目更新submodule的内容首先要提交submdoule的内容,然后再更新主项目中引用的submodulecommit id 总得来说,submodule 中修改了内容,并且做了commit,需要告诉主项目,我已经更新了,你也提交一下。

如果通过发PR的形式,合并之后会产生额外的commit_id,但是这个commit_id并没有“通知” 到主项目,这时需要自己在本地更新一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment