Skip to content

Instantly share code, notes, and snippets.

@justinweiss
justinweiss / init.el
Created November 4, 2008 21:11
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))