git submoduleの更新
2017.8.31 追記
この記事は間違っています。正しくは下記でした。
git submoduleの更新方法を勘違いしていた
昔書いた記事を参考にしてくださった方がいて、
でも「git submodule updateで更新できないよ」と。
gitのsubmoduleだけを最新版にしたい場合のコマンドメモ - Reinvention of the Wheel
私自身もgit submodule updateで更新できると思ってました。
というか、一度も更新処理試してなかった。
結論から言うと
これでOKでした。foreach便利。
$ git submodule foreach 'git pull origin master' $ git submodule update
ですが、no branch になってしまってるsubmoduleがあったので、pullするのはこっちの方がいいかもしれません。
(もしくはfetchでも)
git submodule foreach 'git checkout master; git pull'
試したこと
とりあえず
git submodule updateしてみると反応無し。
あら。
$ git submodule update
困ったのでhelp
$ git submodule -h Usage: git submodule [--quiet] add [-b branch] [--reference <repository>] [--] <repository> [<path>] or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...] or: git submodule [--quiet] init [--] [<path>...] or: git submodule [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...] or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...] or: git submodule [--quiet] foreach [--recursive] <command> or: git submodule [--quiet] sync [--] [<path>...]
$ man git-submodule update Update the registered submodules, i.e. clone missing submodules and checkout the commit specified in the index of the containing repository. This will make the submodules HEAD be detached unless --rebase or --merge is specified or the key submodule.$name.update is set to rebase or merge. If the submodule is not yet initialized, and you just want to use the setting as stored in .gitmodules, you can automatically initialize the submodule with the --init option. If --recursive is specified, this command will recurse into the registered submodules, and update any nested submodules within. foreach Evaluates an arbitrary shell command in each checked out submodule. The command has access to the variables $name, $path and $sha1: $name is the name of the relevant submodule section in .gitmodules, $path is the name of the submodule directory relative to the superproject, and $sha1 is the commit as recorded in the superproject. Any submodules defined in the superproject but not checked out are ignored by this command. Unless given --quiet, foreach prints the name of each submodule before evaluating the command. If --recursive is given, submodules are traversed recursively (i.e. the given shell command is evaluated in nested submodules as well). A non-zero return from the command in any submodule causes the processing to terminate. This can be overridden by adding || : to the end of the command. As an example, +git submodule foreach 'echo $path `git rev-parse HEAD`'+ will show the path and currently checked out commit for each submodule.
foreachを使用するのがよさそうです。
updateは誤解していました。
git submodule summaryとかもあるのね。
git submodule syncはurl変更用っぽいです。