Friday, February 4, 2011

Git for Windows and Emacs

If you are developing source code on Windows with Emacs and you want to use Git to track your changes, I have found a nice setup using Git for Windows  (formerly named msysgit) with NanoEmacs.  If you don't have Emacs installed, here is another post with the basic steps to get you started.

Here are the steps to set up Git to run in a bash shell with an Emacs compatible editor for commit messages.

1. Download and install Git for Windows.  It will prompt you about line endings.  I do not use the automatic line feed conversion, there are reports of problems and I can control it fine within Emacs (here is a link to some Emacs line ending commands).  If you aren't sure about this choice, you can change it after installation at the git command line using 'git config.'

2. After installation, enter some essential configuration settings in the Git command shell.
$ git config --global auto.crlf false
Update: on newer versions this setting has changed
$ git config --global core.autocrlf false

Change a few other defaults that you might need
$ git config --global user.name "Your Name"
$ git config --global user.email yourname@yourdomain.com

3.  I wanted a small emacs compatible editor for commit messages.  I found Jasspa's NanoEmacs console version.  Download the latest, at the time of writing it's jasspa-ne-ms-win32-20091011.zip. You will also need this ne.emf file.  The Download page has a few more versions, extras, and manuals.

4. Copy NanoEmacs executlable, ne32.exe, to a directory in your path.   I have a bin directory under my home directory for small utility programs.

5. Configure NanoEmacs as the default editor for Git.  Substitute the an executable path for /c/ac/bin
$ git config --global core.editor /c/ac/bin/ne32.exe

Updated on Nov 22, 2016 with new crlf setting and new link to Git for Windows.

No comments: