As I couldn't find a comprehensive docu on using git in emacs I am aggregating everything I need for daily work here. (hopefully the list will grow by time) You can use the VC (git support is part of emacs since >=22.1) respectively the DVC extension of emacs but it's not the way I wanted to have an interface to git. If you want to do so i found this article useful on the VC and this useful on the DVC mode.
After evaluation I've decided to use git.el which is part of the
git distribution. It's for me the more intuitive approach to it and
sadly none of the solutions is perfect. The main points missing for me
are (subset from the TODO list):
- diff against other branch
- renaming files from the status buffer
- creating tags
- fetch/pull
- switching branches
- git-show-branch browser
In gentoo that means we have to install git with emacs USE enabled:
$ USE="emacs" emerge git
Now we have the git.el installed in site-lisp. The problem now
is the way the module is loaded in site-gentoo.el because it's
only loaded if emacs doesn't support git in VC (that's only the case
for emacs < 22.1). So what we have to do is to load the git.el
regardless if it's already supported in VC. Therefore you have to add
the following lines to your ~/.emacs
(add-to-list 'load-path "/usr/share/emacs/site-lisp/git")
(add-to-list 'vc-handled-backends 'GIT)
(autoload 'git-status "git" "Entry point into git-status mode." t)
(autoload 'git-blame-mode "git-blame"
"Minor mode for incremental blame for Git." t)
;keybindindings for git
(global-set-key "\C-xgs" 'git-status)
As you can see I've also added a key binding to get into the
git-status-mode. If you enter C-x g s you'll get a new buffer in
which the actual git-status is shown. I really recommend to use
gitignore else the buffer is getting long in short time.
This
buffer is now your interface to git. The most used shortcuts for me are:
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!
I'd appreciate any improvements sent to me!