Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defun magit-status-parent ()
"Open the magit status of a parent git repository. Useful for
dealing with submodules. Suggest binding to SPC g p for Spacemacs.
(spacemacs/set-leader-keys \"gp\" 'magit-status-parent)
(let* ((child-directory (magit-toplevel default-directory))
(parent-directory (and child-directory
(magit-toplevel (file-name-directory
(directory-file-name child-directory))))))
(if (null child-directory)
(user-error "No child git repository in %s." default-directory)
(if (null parent-directory)
(user-error "No parent git repository in %s." child-directory)
(magit-status parent-directory)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment