You can call magit-status
with prefix-arg (C-u), it will prompt you for git repository. So if you keybinding for magit-status
is C-xg, you can do C-uC-xg, it will prompt for git repo.
You can also set the variable magit-repo-dirs
to a directory (do C-hfmagit-repo-dirs
RET to know more) and it will prompt you for all git repositories in magit-repo-dirs
.
If you use projectile you can use the fact that it remembers your project directories and use it populate magit-repo-dirs
, I have this in my init file to achieve this
(eval-after-load "projectile"
'(progn (setq magit-repo-dirs (mapcar (lambda (dir)
(substring dir 0 -1))
(remove-if-not (lambda (project)
(file-directory-p (concat project "/.git/")))
(projectile-relevant-known-projects))))
(setq magit-repo-dirs-depth 1)))
The code above is executed after projectile
is loaded. It gets the list of projects known to projectile
by doing (projectile-relevant-known-projects)
, iterates through them and adds the projects that have .git/
folder to magit-repo-dirs
, it also sets magit-repo-dirs-depth
to 1 so magit looks for git repos only in the top directories.