Is there a way to make git pull automatically update submodules?

Git config alias. Pullall '! Git pull && git submodule update --init --recursive.

Git config alias. Pullall '! Git pull && git submodule update --init --recursive' If you want arguments to be passed to git pull, then use this instead: git config alias.

Pullall '!f(){ git pull "$@" && git submodule update --init --recursive; }; f.

You're right. I should have tested the code before posting. :-S – wilhelmtell Jan 6 '11 at 4:15 So are you saying if you want to be able to specify a branch name, or use --force, then your second solution is best?

Is there any reason why one would prefer the first solution? – philfreo Jan 7 '11 at 5:28 The first one is easier to read. The second one is what I would actually recommend using in practice.

– Kevin Ballard Jan 7 '11 at 22:25.

Starting with Git 1.7.5 it should update submodules automatically by default like you want it to. The default behavior, "on-demand", is to update submodules whenever you fetch a commit that updates the submodule commit, and this commit isn't already located in your local clone. You can also have it updated on every fetch or never (pre-1.7.5 behavior I assume).

The config option to change this behavior is fetch. RecurseSubmodules. This option can be either set to a boolean value or to on-demand.

Setting it to a boolean changes the behavior of fetch and pull to unconditionally recurse into submodules when set to true or to not recurse at all when set to false. When set to on-demand (the default value), fetch and pull will only recurse into a populated submodule when its superproject retrieves a commit that updates the submodule’s reference. See: git config man page (1.7.5) (or latest git config man page) git fetch man page (1.7.5) (or latest git fetch man page) for more information.

Git fetch --recurse-submodules=yes|on-demand|no.

Watch out: as the answers below explain, this only fetches the changes automatically, you still have to do a submodule update -- so the alias answer is right. – Artem Nov 3 '11 at 16:02.

An alias, as suggested by Kevin Ballard, is a perfectly good solution. Just to toss another option out there, you could also use a post-merge hook which simply runs git submodule update --init.

I haven't earned enough S.O. reputation to be able to comment on other people's answers, so I'm forced to add an answer. Kevin Ballard's git config aliases... answer is the correct answer to the original posted question on automatically running git submodule update after a git pull. Christopher Rogers' fetch.

RecurseSubmodules answer will not automatically run git sumbodule update after a pull (which is what the question was). All this setting does is recurse into each submodule and do a git fetch in that submodule. You'll still need to manually run git submodule update after your pull, regardless of what fetch.

RecurseSubmodules is set to.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions