Skip to content

Instantly share code, notes, and snippets.

@caiorss
Last active February 18, 2017 02:05
Show Gist options
  • Save caiorss/19d37497ffb65853e0d8b3563f134ffa to your computer and use it in GitHub Desktop.
Save caiorss/19d37497ffb65853e0d8b3563f134ffa to your computer and use it in GitHub Desktop.
Magit with multiple profiles
;;;; ================= Way 1 =================
;; Before commit with work profile use M-x magit-status-work
;;
(defun magit-status-work ()
(interactive)
(setenv "GIT_AUTHOR_NAME" "work user")
(setenv "GIT_AUTHOR_EMAIL" "[email protected]")
(magit-status default-directory))
;; Before commit with home profile use M-x magit-status-home
;;
(defun magit-status-home ()
(interactive)
(setenv "GIT_AUTHOR_NAME" "home-user")
(setenv "GIT_AUTHOR_EMAIL" "[email protected]")
(magit-status default-directory))
;;; ============== Way 2 ==================
;;
;; set magit user definitively for current Emacs session before run magit-status.
;;
(defun magit-home-mode ()
(interactive)
(setenv "GIT_AUTHOR_NAME" "home-user")
(setenv "GIT_AUTHOR_EMAIL" "[email protected]"))
(defun magit-work-mode ()
(interactive)
(setenv "GIT_AUTHOR_NAME" "work user")
(setenv "GIT_AUTHOR_EMAIL" "[email protected]"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment