I have just installed Magit and so far all is going great! However, I have a lot of GitHub repos that I would like to fetch via Magit. Is there a way to fetch all repos from GitHub?
1 Answer
Magit does not come with a command to do that, but implementing it is easy.
(defun my-magit-fetch-all-repositories ()
"Run `magit-fetch-all' in all repositories returned by `magit-list-repos`."
(interactive)
(dolist (repo (magit-list-repos))
(message "Fetching in %s..." repo)
(let ((default-directory repo))
(magit-fetch-all (magit-fetch-arguments)))
(message "Fetching in %s...done" repo)))
You will have to customize magit-repository-directories
to tell Magit about the repositories magit-list-repos
should return
That function is also used when invoking magit-status
with a prefix argument to jump to some repository and other things. If you want to only fetch in some of the returned repositories, then you will have to implement some filtering. This could for example be based on the value of (magit-get "remote.origin.url")
to limit to only repositories from Github.
-
+1. Note that this assumes existing checkouts of the repositories in question; it does not automatically ascertain which repositories a particular user has on GitHub.– BasilCommented Jun 21, 2017 at 17:22