SiteMap Search ElispArea HowTo Glossary RecentChanges News Problems Suggestions
Eritrea, Independence Day

Git

Git is a distributed version control system much like Mercurial, Bazaar and DaRcs. It was written for the linux kernel hackers but it is now used by other high-profile FreeSoftware projects.

Emacs Standard Support

Git is supported by vc-git since 22.1, accessible via VersionControl.

vc-git is reported to work well. There are two front end wrapper packages that can be used with vc-git:

  1. git-emacs, which provides status bar icons for git status
  2. git.el and git-blame.el (a frontend to the git-blame command line tool) which are distributed in the Git source distribution in the contrib/emacs directory (already installed in Debian as part of git-core, or more recently in the separate git-el package). The README file supplied in contrib/emacs explains how to install them. Some introductory tutorial material located at Up and Running with Emacs and Git

The command showing the repository status ‘C-x v d’ supports checking in multiple files/directories at a time, and it has fancy display. It can be extended with git specific functions. vc-git-grep can be used as a UI for git grep. vc-git.el also includes support for git blame, in the vc-annotate command ‘C-x v g’.

Magit is the most popular interface to git. If you are new to git and do not need support for other vcs this is likely the package you should try first.

Egg (Emacs got Git) was forked from Magit and has developed independently since 2008 (Homepage, Documentation, Blog including screenshots), stable and bleeding-edge project pages). Egg has built-in blame-mode that can relocate the blamed commit back into the DAG view (log-buffer.) Normally unreachable commits in the reflogs can also be brought back into the DAG view, making refs recovery error-proof. Egg supports interactive rebase by marking directly on commits (to be picked, edited or squashed) in the DAG view. Egg also has extensive support for pickaxing (only showing the diffs with the search term, highlighting the search term, etc.) The default colours are terrible but can all be customized.

DVC is a generic Emacs interface to DistributedVersionControl systems, including git.

egit is an Emacs Git history interface intended to be similar to qgit or gitk (Homepage). Requires git.el.

Gitsum is a mode to do interactive partial commits with Emacs in the style of darcs record (Homepage, Introduction).

git-emacs is yet another git mode on Emacs for newbies (Homepage, Documentation).

mo-git-blame is an interactive and iterative major mode for git blame (Homepage, Documentation).

tortoise-git.el is a simple interface to Tortoise Git within Emacs (Homepage, Repository).

GitDwim defines context-aware commands.

Also see

Configuration

Debian

If you are using the Debian git packages, you can add the following to your .emacs to make all of these available (if you are not using the Debian packages, adjust the path to suit):

Note: This does not work in Emacs 23.0 - git is included.

  (setq load-path (cons (expand-file-name "/usr/share/doc/git-core/contrib/emacs") load-path))
  (require 'vc-git)
  (when (featurep 'vc-git) (add-to-list 'vc-handled-backends 'git))
  (require 'git)
  (autoload 'git-blame-mode "git-blame"
            "Minor mode for incremental blame for Git." t)

git.el will look into your git configuration for committer name and email address. If that fails, it uses the Emacs defaults. If you rely on environment variables for your configuration, beware. (And consider ‘git-committer-name’ and ‘git-committer-email’)

How to use Git with VC

Question: I would like to do everything from within Emacs (without having to resort to the command-line). I was able to create a new repository with ‘vc-create-repo’, but don’t know how to add all the files in the directory with ‘vc-next-action’ – something akin to (eventually calling the backend command) git add . – without having to add each file separately. Any tips?

Answer: With vc-git.el 2007-11-29 or later, you can do

NOTE: This does not seem to work with remote repos (vc-git.el 2010-03-09).

Question: How do I revert an uptodate file to a previous version? How do I manage branches?

[1]: Sorry, but it is absolutely unclear what vc-git.el (coming with emacs23) provides. Neither Info nor vc-git.el give any information about what works with remote repositories and how (cloning, staging, registering, commiting, …). What is stash? What is the master-file? Why does vc-dir not show the remote-url?


CategoryVersionControl