I would like to determine if the current directory/file is ignored by .gitignore with vc. In this case, only git matters, but of course a general solution would be appreciated.

1 Answer 1


I'm afraid there is no such API in vc-mode or magit, but with little elisp you can implement all by yourself:

(defun my/is-git-ignored (file)
  (interactive "fFile:")
  (not (string-empty-p
        (shell-command-to-string (concat "git check-ignore " file)))))

Your Answer

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

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