Magit

One of the first things I did when I started using Emacs was to install the git.el package that interfaces with Git. I chose git.el because it worked the same as the rest of the Emacs source control interfaces. There’s not much to do to install the package but somehow I must have messed it up because I could never get it to commit.

I use Git mostly to keep versioned backups of my work and to move data between the machines that I use. I have Git repositories on a local server that I can push to and pull from. It’s not hard to pop into a shell buffer and just call Git by hand and that’s what I fell into doing. Every once in a while I would try M-x git-status again and, of course, it still didn’t work. I checked that I had the latest version but other than that I didn’t look into the problem further.

All this time, what I really wanted to use was magit but I had it in my head that it was better to stick with a package that had a UI the same as for all the other SCM systems. Then one day it occurred to me that I use only Git and that, gee, maybe I could learn another interface if the need arose. But I still didn’t install magit. I know, I know, I’m a lazy, lazy person.

A few days ago I saw this video by Alex Vollmer and decided that I really should give it a spin. I’m very pleased that I did. The result is similar to what happened when I discovered I could FTP right out of dired. It hasn’t changed my life but it has made my work flow easier and more efficient. Even more important, I find that I do a lot more commits and pushes than I did before. I used to put off committing until I had several files or until I needed to refresh my files on another machine. Now it’s so simple that I do it as soon as I finish with a file. That means the repositories on the server are always up to date and I don’t have to trudge over to my main machine to push everything so that I can pull it onto another machine—I just pull and get the latest files.

It turns out that magit is very sensitive to the .git/config files so if you want to use it you will need to get those right. Here’s what I have for my local set up.

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
[remote "org-repo"]
        fetch = +refs/heads/*:refs/remotes/org-repo/*
        url = ssh://bedia/home/jcs/repos/org.git
[branch "master"]
        remote = org-repo
        merge = refs/heads/master

The [core] section of the configuration was auto-generated by Git, and the [branch "master"] section was generated by magit. That leaves the fetch line in the [remote "org-repo"] section. If you don’t have that, things will still work, mostly, but you get error messages in your magit-status buffer for some of the remote items.

This entry was posted in Programming. Bookmark the permalink.