git submodule 的那几个命令每次查完都记不住, 所以这次就在这里好好思考一下其原理, 希望以后不要再忘了.
git submodule 的原理是在父模块中记录子模块的 commit, 并监控记录的 commit 和子模块的 HEAD 的差异.
父模块所记录的子模块 commit 属于父模块的版本信息, 这一信息的改变不会实际影响子模块的 HEAD. 当 cd 到子模块中做了一些更改提交, 或者父模块从远程 fetch 最新改动, 只要是会导致父模块记录的 commit 和子模块中 HEAD 不一样时, 父模块 git status 就会显示出这一差异, git submodule update
命令会将子模块的 HEAD 指向父模块中记录的 commit id, 从而抹平这一差异.
如果想让子模块的 HEAD 更新到子模块的远程最新, 就用 git submodule update —remote
, 这样一来子模块的 HEAD 一般往往也就比父模块记录的 commit 要新了, 父模块 git status 自然也会显示差异, 父模块可以提交这一信息将其记录在自身 --- 这就是父模块 "携带" 某个特定版本子模块的方法.
为来自祖国的大咖点赞
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
多谢~ 不过我不是大咖, 一起学习~
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
一起加油👌
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
为来自祖国的大咖点赞
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
为来自祖国的大咖点赞
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You should follow @icowatchdog. ICO Watchdog is your comprehensive solution to following the cryptocurrency market. Follow the market with 100% Free and Real-time cryptocurrency alerts for all your favorite messaging applications today. Follow @icowatchdog Steemit account for news updates and token sales/air drops.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit