Emacs: How to Build Emacs from git Repository

By Xah Lee. Date: . Last updated: .

This page shows you how to compile emacs from developer version of source code on git repository. I assume you are using Ubuntu Linux.

building emacs eshell 2017 07 25
building emacs from git

Building Emacs from Git

If you have not build emacs on Linux before, you need to first install built tools and dependent libraries that emacs use. See: How to Build Emacs on Linux. Basically, just run the following first:

# install essential build tools
sudo apt-get install build-essential

# get all dependencies of a previous emacs version
sudo apt-get build-dep emacs25

Now clone emacs from its github mirror.

# clone emacs from github mirror
git clone https://github.com/mirrors/emacs.git

It'll create a dir named emacs in the current dir. [see git Tutorial]

if you have build from git before, you might want to clean your repo first.

cd ~/mygit/emacs

# discard stuff from last build
git reset --hard

# delete all of the last build stuff
git clean -xdf

# get latest update
git pull https://github.com/mirrors/emacs.git

cd to the emacs git repo. In the dir, there's a file named INSTALL.REPO that tells you how to build from repository. But, basically, you just run:

# build emacs from git repo
cd ~/mygit/emacs
make bootstrap

The whole process will take about 20 minutes.

When done, the emacs binary will be at dir src. For example, you can start it by:


You can prepend the path to your shell, so next time you just type “emacs” to launch. Put the following line at bottom of your ~/.bashrc.

# prepend emacs path to environment variable PATH
# make sure the dir is correct

That's all!

After a few months, you can git pull the emacs git repository to get update, then compile again.