According to the Magit manual the combination C-x g (magit-status) shows

the status of the current Git repository in a buffer.

How can I view what the current Git repository is, i.e. the full path to it or alternatively the path relative to my home directory?

1 Answer 1


Proposal 1

For any Emacs buffer, you can invoke M-x pwd in order to display the current working directory, as determined by variable default-directory.

Proposal 2

The user option magit-buffer-name-format determines the name of Magit buffers and always contains the format specifier %t, which corresponds to the top-level directory of the repository's working tree.

The user option magit-uniquify-buffer-names defaults to t, which results in %t expanding to an abbreviated and uniquified representation of the current top-level directory.

If you don't mind the increased hogging of mode line real estate, you can set magit-uniquify-buffer-names to nil (e.g. via (setq-default magit-uniquify-buffer-names nil)) in order to have the full directory path displayed in the mode line (and as part of the name) of each Magit buffer.

Proposal 3

Following Kyle Meyer's suggestion, you could write your own command along the lines of

(defun my-git-pwd (&optional insert)
  "Show the toplevel of the current repository.
With prefix argument INSERT, insert the current default directory
at point instead."
  (interactive "P")
    (pwd insert)))

Proposal 4

If you don't want to waste any horizontal space in the mode-line as suggested in (2), you can instead "waste" a single line in the status buffer itself:

(magit-add-section-hook 'magit-status-headers-hook

You can control where this additional information appears, see magit-add-section-hook's doc-string.

  • Regarding Proposal 1: the current working directory is not necessarily the current Git repository.
    – Evan Aad
    Commented May 22, 2017 at 12:14
  • Regarding Proposal 2: And what if I do mind the increased hogging of mode line real estate? Is there no way of querying magit for the path the to current Git repository (the one whose status will be displayed when the combination Cx g is executed)?
    – Evan Aad
    Commented May 22, 2017 at 12:18
  • @EvanAad These two proposals are off the top of my head, I'm looking into it as we speak out of my own curiosity. Perhaps I should have written "possibility" instead of "proposal".
    – Basil
    Commented May 22, 2017 at 12:19
  • I understand. By the way, how can I view and set the user options you mentioned?
    – Evan Aad
    Commented May 22, 2017 at 12:21
  • 1
    magit-toplevel will return the directory that Magit considers to be the root of the current repo.
    – Kyle Meyer
    Commented May 22, 2017 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.