How to change repo using magit emacs?

I need to work with multiple git repositories. How to switch between them using magit? Magit allows me to select a directory when I am just starting it .. But I don’t understand how to switch to another repo if necessary. I looked at the mahitic cheatsheet and documents, but could not find an answer. Thanks.

+4
source share
3 answers

You can call magit-statususing prefix-arg ( C-u), it will prompt you to create a git repository. So, if you bind keybinding for magit-status C-x g, you can do it C-u C-x g, it will suggest git repo.

You can also set the variable magit-repo-dirsto a directory (do C-h f magit-repo-dirs RETto find out more) and it will offer you all git's repositories magit-repo-dirs.

If you use a projectile, you can use the fact that it remembers your project directories and uses it to fill magit-repo-dirs, I have this in my initialization 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 above code is executed after loading projectile. He gets a list of projects known projectile, performing (projectile-relevant-known-projects), iterates through them and adds projects in which .git/folder on magit-repo-dirs, and sets magit-repo-dirs-depthto 1 so magit looking git repos only the top directories.

+10
source

, , :

(setq projectile-switch-project-action 'projectile-vc)

C-p p s (projectile-switch-project), projectile-vc, , magit, magit-status . !

+5

John Wiegley "Springboard", .

https://github.com/jwiegley/springboard

helm / ido, , , , . (README ), :

  • , 1.el, git magit-status 2.el, .

  • M-x springboard helm ido-switch-buffer ido
    -.

  • 2.el ( ), , .

  • , 2.el, magit-status , magit-status , 2.el, , , magit 1.el , , , springboard.

.

+3

Source: https://habr.com/ru/post/1528073/


All Articles