How does one disable vc-git in emacs?
Asked Answered
S

5

30

I'm using emacs over sshfs and a git repository. I enjoy using the git command line and so for this project I do not need vc-git enabled. How do I prevent the loading of vc-git by a .emacs command?

Saidel answered 21/4, 2011 at 19:25 Comment(0)
C
16

Remove it from find-file-hook. This should disable the backend:

(remove-hook 'find-file-hook 'vc-find-file-hook)

you might need a (require 'vc) before the above line to get the timing right. Or perhaps wrap it like so:

(eval-after-load "vc" '(remove-hook 'find-file-hook 'vc-find-file-hook))

to get the timing right.

Chesty answered 21/4, 2011 at 19:48 Comment(1)
I also had 'vc-refresh-state in the hook so I've removed it as well (remove-hook 'find-file-hook 'vc-refresh-state)Dialect
C
53

Remove git from the list of backends handled by vc-mode:

(delete 'Git vc-handled-backends)

or remove all source control hooks:

(setq vc-handled-backends ())
Comrade answered 31/5, 2011 at 16:2 Comment(4)
+1 (setq vc-handled-backends ()) worked just fine. Not only Emacs starts faster now, but file opening is much quicker too, thanks!Graciagracie
This variable can also be modified or cleared using customize.Impediment
The solution with delete is incorrect because delete does not modify the argument, just returns the modified list. Use this instead: (setq vc-handled-backends (delete 'Git vc-handled-backends))Nebula
Here in 2023, I suddenly experienced unacceptable waiting times when opening files under a git clone folder with Emacs/Cygwin. Adding (delete 'Git vc-handled-backends) to .emacs solved the problem. (setq vc-handled-backends (delete 'Git vc-handled-backends)) also worked, but I saw no difference between the two.Haag
C
16

Remove it from find-file-hook. This should disable the backend:

(remove-hook 'find-file-hook 'vc-find-file-hook)

you might need a (require 'vc) before the above line to get the timing right. Or perhaps wrap it like so:

(eval-after-load "vc" '(remove-hook 'find-file-hook 'vc-find-file-hook))

to get the timing right.

Chesty answered 21/4, 2011 at 19:48 Comment(1)
I also had 'vc-refresh-state in the hook so I've removed it as well (remove-hook 'find-file-hook 'vc-refresh-state)Dialect
C
7

Or you can disable the entire version control thing in emacs

;;disable the version control

(setq vc-handled-backends nil) 

worked for me.

Culver answered 30/4, 2012 at 11:17 Comment(0)
M
2

I'd also really recommend magit (a different emacs git mode.) I, too, prefer command line for everything but this one's really well done and allows you to code more and "git" less. Particularly staging and unstaging code / seeing a diff of your changes before sending them out, viewing stashes, and pulling / pushing while staying inside of emacs is great.

Mythologize answered 1/5, 2011 at 6:9 Comment(0)
D
0

This also works:

(setq vc-ignore-dir-regexp ".+")

or

(setq vc-ignore-dir-regexp "")

as sugested by @Stefan in comment

this will speed up reading as well as saving files. and you can provide the regex you want so you can make git work for some directories and don't for others.

Dialect answered 18/7, 2018 at 12:5 Comment(2)
@Stefan yes it should be ".+" I though that . need to be escaped, it was working because it matched .git directory.Dialect
".+" would mean "ignore any dir whose name has at least one non-LF char in it". IOW, it ignores all dirs except the directories called "", "\n", "\n\n", ... I think it's a rather odd choice: "" is shorter and means "ignore all dirs", which sounds closer to what you're suggesting.Gooseneck

© 2022 - 2024 — McMap. All rights reserved.