complete-computing-environment/magit.org

2.2 KiB

Git in Emacs with Magit

I use git-messenger, git-timemachine, and Magit in a custom Hydra binding. As described in my Basic Emacs Coding Config, I use git for my source code management, and Magit is a really top-notch frontend for it. It exposes nearly all Git functionality on mnemonic keybindings.

(use-package git-timemachine)
(use-package git-messenger)
(use-package magit
  :after (git-timemachine git-messenger)
  :config 
  (defhydra hydra-magit (global-map "C-c g" :color teal :hint nil)
    "
       PROJECTILE: %(projectile-project-root)
  
       Immuting            Mutating
  -----------------------------------------
    _w_: blame line      _b_: checkout
    _a_: annotate file   _B_: branch mgr
    _d_: diff            _c_: commit
    _s_: status          _e_: rebase
    _l_: log
    _t_: time machine
  
  "
    ("w" git-messenger:popup-message)
    ("a" vc-annotate)
    ("b" magit-checkout)
    ("B" magit-branch-manager)
    ("c" vc-next-action)
    ("d" magit-diff-working-tree)
    ("e" magit-interactive-rebase)
    ("s" magit-status)
    ("l" magit-log)
    ("t" git-timemachine))
  :bind
  ("C-c g" . #'hydra-magit/body)
  (:map evil-leader--default-map
         ("g" . hydra-magit/body)))

(provide 'cce/magit)
{...}:
{
  programs.git = {
    enable = true;
    userName = "Ryan Rix";
    userEmail = "ryan@whatthefuck.computer";
    extraConfig = {
      core = { excludesfile = "~/.gitignore"; };
      init = { defaultBranch = "main"; };
    };
  };
}