Sunday, 20 February 2011

Tell emacs to use git instead svn or cvs when a file is managed by both versions systems.

Stack overflow is wonderfull, I posted a question and it was answered in less than a minute. Was so quick that I needed to wait for 4 minutes before being able to accept it!.

In short: if you have a file managed by Git and several other versions systems and you want to use emacs VC shortcuts with Git, you need to edit vc-handled-backends and move Git the first one.

'(vc-handled-backends (quote (Git CVS SVN SCCS Bzr Hg Arch MCVS)))

I have also added git.el to my site-lisp

$ cp /usr/share/doc/git/contrib/emacs/git* ~/.emacs.d/site-lisp/

And then added to my .emacs
;; from git.el (complement to vc-git.el)
(require 'git)
(require 'git-blame)

then creating a keybinding (from
;keybindindings for git
(global-set-key "\C-xgs" 'git-status)

git.el shortcuts
m - mark the file the cursor is on ATM
M - mark all files in buffer
u/DEL - unmark file below/above
R - resolve conflicts during merge
a - add file to repository
r - remove file
i - add file to ignore list
c - commit
U - Undo -> revert file
l - see log file
g - refresh the status buffer
q - quit status buffer
? - get help!