Context: I have a relatively small project, in which I use branches to work on new features, so that when I'm finished, then I manually merge branches as I need.

I usually keep the same exact copy of my branches on many machines as I work remotely, and that's what I need. I'm not using GitHub, my remote server is just a Server of my company where we keep projects on.

So the question is: How do I push, or fetch all branches at once using magit?

What I'm trying to achieve is the same exact output that I would have by executing these commands in the terminal:

git push --all


git fetch --all

More info;

  • Emacs version: GNU Emacs 25.3.1 (x86_64-w64-mingw32) of 2017-09-17

  • Magit version: 20190202.1535

If more is needed don't mind asking. Thanks in advance!

2 Answers 2



With the default Git configuration, fetching a remote will fetch all branches (i.e. all the refs the remote has under refs/heads/). So, from within Magit, you shouldn't need to do anything other than fetching the remote. If the remote is configured as the upstream, that would be F u with the default Magit bindings.

If you want to fetch all remotes (not just all branches from a single remote), you can do that with Magit's magit-fetch-all command (F a), as mentioned by @Prgrm.celeritas.


Magit doesn't have a command that does something like git push --all REMOTE. As mentioned in another answer, you can run a custom Git command via the Magit interface.

Another option is to define a command yourself. For example,

(defun my/magit-push-all ()
  "Push all branches."
  (magit-run-git-async "push" "-v"
                       (magit-read-remote "Remote")

And then bind that command in the push popup:

(magit-define-popup-action 'magit-push-popup
  ?a "Push all" #'my/magit-push-all)

If you have magit ≥ v3.0.0 (May 2021), you need to use transient instead of magit-define-popup-action:

(transient-append-suffix 'magit-push '(2 0 -1)
'("a" "push all" my/magit-push-all))

(2 0 -1) means the command is placed at the end (-1) of the first subgroup (0) of the third group (2) in magit-push.

  • Excuse me for the question; it is unclear to me to what you refer to as "Remote". Both in the code example and in the fetching part. In my case my only one remote is called origin. How can I set origin to be the remote for these commands that you pointed out?
    – Johwhite
    Commented Feb 11, 2019 at 16:15
  • 1
    "Remote" was a general reference to any remote repository, but in the scenario you describe it'd be origin. For fetching, you can configure origin/master as the upstream branch for master (with the default Magit configuration, that'd be bu then select "origin/master"). Then you can fetch all branches on that remote with Fu ("fetch upstream"). For pushing with the custom command above, it will prompt you to choose a remote from all possible remotes. Because this is just "origin" in your case, you could replace (magit-read-remote "Remote") with "origin".
    – Kyle Meyer
    Commented Feb 12, 2019 at 16:46
  • 1
    This throws a warning as Magit uses transient now instead of popup actions
    – Fabman
    Commented Aug 19, 2021 at 9:14

fa will fetch all remotes. I don't know if there is a way to push all remotes though. You could always use !! then push --all. !! lets you run any git command in the git root. Its what I use when magit doesn't have a popup option I need.

  • Thanks for your answer. fa is doing exactly what I needed for the download part.
    – Johwhite
    Commented Feb 11, 2019 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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