I used to be able to press "o" then "u" (magit-submodule-update) in a magit buffer and have it update all my submodules. Now, it asks me to type in the path of which submodule I want to update. Is there a way to go back the the old behavior where all submodules were updated?

My submodules are somewhat buried in a directory structure, so having to type them in each time is annoying (not to mention, I have more than one).

I'm currently using Magit 20180220.1117, Git 2.15.1, Emacs 25.3.1, darwin


I got caught out by this as well when it changed. A couple of ideas:

  • As the documentation posted in another answer notes, you can use the universal argument (C-u) before a submodule operation to apply it to all.

  • You can add custom commands to the submodules popup which emulate the old behaviour. Either by writing a function which passes the prefix argument to an existing command (my elisp-fu was too weak to make this work), or by running a custom git command line:

    (defun magit-submodule-update-recursive ()
      (magit-run-git-async "submodule" "update" "--init" "--recursive"))
    (eval-after-load "magit" '(magit-define-popup-action 'magit-submodule-popup
                        ?U "Update all (recursively)" 'magit-submodule-update-recursive))

    With this in init.el, o U will update all submodules. Adapted from this issue comment.

2020 EDIT: Recent magit versions no longer use magit-popup but use transient instead, so the above no longer works. Working from the guide for translating magit-popup to transient, I have this now:

(use-package magit

  (define-suffix-command magit-submodule-update-all ()
    "Update all submodules"
    :description "Update All (git submodule update --init --recursive)"
      (magit-run-git-async "submodule" "update" "--init" "--recursive")))

(I also switched to using use-package for all my Magit config, instead of eval-after-load.)

| improve this answer | |
  • This is the real answer to the question. You should now press o C-u u to update all submodules with default magit configuration. – Sergei Nosov Dec 6 '18 at 13:38
  • One closing parenthesis is missing. (Edits need to be longer than 6 characters.) – Zelphir Kaltstahl Feb 21 '19 at 8:56
  • @Zelphir fixed, thanks – projectgus Feb 22 '19 at 5:24

Often such questions can be answered simply by consulting the documentation. The section about the Submodule Popup contains this:

Some of the below commands default to act on the modules that are selected using the region. For brevity their description talk about "the selected modules", but if no modules are selected, then they act on the current module instead, or if point isn't on a module, then the read a single module to act on. With a prefix argument these commands ignore the selection and the current module and instead act on all suitable modules.

If you are unsure what "the modules that are selected using the region" means, then read about that in the manual. I would recommend you also read some of the close by nodes, maybe even read about all Interface Concepts.

By default Magit does not insert any module sections into the status buffer, but you can learn how to do that at Status Module Sections.

The buffer created by the command magit-submodule-list uses the mode tabulated-list-mode, which is an user interface abstraction different from the one Magit uses in most of its buffers. If you use the region to select multiple lines here, then Magit commands won't recognize that as a selection.

It is also easy to get documentation about an action (or argument) directly from the popup by pressing ? followed by the key(s) that would invoke the action (or argument) had you not pressed ? first.

Though in this case the doc-strings did not mention how these commands determine the module(s) to act on, which I have fixed now.

| improve this answer | |
  • Where does one select a module (submodule?) with the region? A magit-submodule-list buffer would seem to be the place, but doesn't apparently have any key bindings for updating. – andy turk Feb 22 '18 at 1:28
  • I have updated my answer to address these follow up questions. – tarsius Feb 22 '18 at 2:14
  • 2
    Press o, then C-u u to update all submodules. – user30747 Oct 23 '18 at 18:34

The headline question was, "Why does magit now prompt for which submodule to update?"

The answer is simply that magit's default interface changed at some point. (I believe) magit used to automatically operate on all submodules, but now requires an explicit selection in the submodules status section or a path.

The second question was, "Is there a way to go back the the old behavior where all submodules were updated?"

Apparently not, but there is a workaround that gets close. To use it, it's important to ensure that submodule information is visible in magit's status buffer:

(magit-add-section-hook 'magit-status-sections-hook

Simply select all the submodules shown in the overview and then "o" "u" as before.

The magit documentation talks about "modules that are selected using the region," but unless module information is displayed, it can't be selected, much less seen. This was my confusion earlier--my magit configuration was not displaying any submodule information in the status buffer.

I discovered the missing hook in a magit issue discussion thread. Note that the original magit-insert-submodules mentioned in that discussion has changed to magit-insert-modules-overview as of version 2.11.0.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.