Update Git submodule to latest commit on origin -
i have project git submodule. ssh://... url, , on commit a. commit b has been pushed url, , want submodule retrieve commit, , change it.
now, understanding git submodule update
should this, doesn't. doesn't (no output, success exit code). here's example:
$ mkdir foo $ cd foo $ git init . initialized empty git repository in /.../foo/.git/ $ git submodule add ssh://user@host/git/mod mod cloning mod... user@host's password: hunter2 remote: counting objects: 131, done. remote: compressing objects: 100% (115/115), done. remote: total 131 (delta 54), reused 0 (delta 0) receiving objects: 100% (131/131), 16.16 kib, done. resolving deltas: 100% (54/54), done. $ git commit -m "hello world." [master (root-commit) 565b235] hello world. 2 files changed, 4 insertions(+), 0 deletions(-) create mode 100644 .gitmodules create mode 160000 mod # @ point, ssh://user@host/git/mod changes; submodule needs change too. $ git submodule init submodule 'mod' (ssh://user@host/git/mod) registered path 'mod' $ git submodule update $ git submodule sync synchronizing submodule url 'mod' $ git submodule update $ man git-submodule $ git submodule update --rebase $ git submodule update $ echo $? 0 $ git status # on branch master nothing commit (working directory clean) $ git submodule update mod $ ...
i've tried git fetch mod
, appears fetch (but can't possibly, because it's not prompting password!), git log
, git show
deny existence of new commits. far i've been rm
-ing module , re-adding it, both wrong in principle , tedious in practice.
the git submodule update
command tells git want submodules each check out commit specified in index of superproject. if want update submodules latest commit available remote, need directly in submodules.
so in summary:
# submodule git submodule add ssh://bla submodule_dir git submodule init # time passes, submodule upstream updated # , want update # change submodule directory cd submodule_dir # checkout desired branch git checkout master # update git pull # project root cd .. # submodules in state want, git commit -am "pulled down update submodule_dir"
or, if you're busy person:
git submodule foreach git pull origin master
Comments
Post a Comment