Skip to content

Instantly share code, notes, and snippets.

@justinweiss
Created November 4, 2008 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinweiss/22216 to your computer and use it in GitHub Desktop.
Save justinweiss/22216 to your computer and use it in GitHub Desktop.
get git root directory
(defun my-git-root ()
(let* ((current-directory (file-name-directory buffer-file-name))
(git-directory (concat current-directory ".git")))
(while (and
current-directory
(not (file-exists-p git-directory)))
(setq current-directory (file-name-directory (substring current-directory 0 -1)))
(setq git-directory (concat current-directory ".git")))
current-directory))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment