Created
November 4, 2008 21:11
-
-
Save justinweiss/22216 to your computer and use it in GitHub Desktop.
get git root directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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