By default, when i do M-x helm-do-grep, helm prompts to search from the current buffer's folder location. I would prefer it to list the git repository's base folder (where .git folder is located) as the default string in minibuffer and search recursively down all sub folders.

How to configure helm to automatically identify folder with .git contents as base folder and use it for all search activities?

  • I wouldn't recommend doing that because you will end up at some point having multiple projects, some of which are not version-ed by git. So this kind of change won't be beneficial. Instead you should press C-. until you hit the root of the project.
    – caisah
    Jun 5, 2015 at 11:05
  • i realised that sometime later... and yes, your solution fixes that.....
    – Saravana
    Jun 5, 2015 at 14:09

2 Answers 2


Probably not the direct nor best solution to your problem, but it does the trick:

(defun my-grep-repo ()
  (helm-do-grep-1 '("/path/to/root/project")
                  '("*.py" "*.py")))

You can also replace the '(path/to/root/project) by the returned value of vc-root-dir or magit-get-top-dir



if your are in hybrid mode, you need in 'insert mode', because when you are in 'emacs mode', you can use C-u to add an Prefix and then use helm-grep-do-git-grep

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.