Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To compile upstream Git on Ubuntu, install the build dependencies, obtain a tagged Git release, run make configure, configure it with an installation prefix, compile it, and install the binaries. The documented sequence is:

sudo apt-get update
sudo apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
cd git-2.56.0
make configure
./configure --prefix=/usr
make all
sudo make install

Add the documentation packages and the doc and info targets when you also want Git’s man pages, HTML documentation, and Info files. Building from source is useful when the upstream release is newer than Ubuntu’s package or you need a customized build; Ubuntu’s package manager remains the simpler default.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When compiling Git from source makes sense

Ubuntu’s repository gives you a Git build integrated with the distribution’s package database, update process, filesystem conventions, and security maintenance. The Git project describes this package-manager route as the easiest way to install Git on Linux.

Source installation is worthwhile when you need a newer upstream release, a build option not enabled by Ubuntu, or a reproducible build process under your control. The Git project’s Linux installation page lists version 2.56.0 as the latest version at the time of writing. Ubuntu Noble’s package metadata lists Git source package version 1:2.43.0-1ubuntu7.3, so an Ubuntu installation can legitimately be behind upstream even when the operating system is fully updated.

#1 Best Overall
Approach Best for Trade-off
Ubuntu package Most users who want a supported, integrated installation May lag behind the latest upstream release
Source tarball Users who need a current upstream version or custom build You must manage compilation, installation, and future updates
Ubuntu source-package workflow Rebuilding or modifying Ubuntu’s packaged Git Uses Ubuntu packaging tools and sources rather than a plain upstream build

Choose one route deliberately. Compiling an upstream release tarball is not the same operation as rebuilding Ubuntu’s package.

Check what Ubuntu already has

Before changing anything, record the Git executable and version currently selected by your shell:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
git --version
command -v git

git --version reports the running Git release. command -v git reports the executable path selected by your PATH. Save both outputs so you can tell whether a later installation changed the command your shell invokes.

If Git is not installed and you only need the distribution build, the short path is:

sudo apt-get update
sudo apt-get install git

Continue with a source build when the repository version or its build options do not meet your requirements.

Understand the installation paths

The canonical upstream example uses --prefix=/usr. That places the compiled files under the system’s normal /usr hierarchy and can put the source-built executable alongside or ahead of files managed by Ubuntu’s package.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because both installations can provide a command named git, verify the resolved path after installation. A source build under /usr does not by itself guarantee that every shell, script, service, or user will run that copy; PATH order determines which executable is found first.

For an isolated installation, you can choose a different prefix when configuring, but the documented sequence in the Pro Git installation chapter uses /usr. If you choose another prefix, use its bin directory in your PATH and check the result with command -v git.

Install the build dependencies

Update APT’s package indexes first, then install the core dependencies documented for a Debian or Ubuntu build:

sudo apt-get update
sudo apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev

These packages provide the build machinery and development headers or libraries needed by Git’s configure and compilation steps. Install them before running make configure; otherwise configuration can stop with missing-tool or missing-header errors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Packages needed for documentation

Git’s documentation targets require additional tools:

sudo apt-get install asciidoc xmlto docbook2x install-info

Do not install these packages merely to produce Git’s binaries. A binary-only build can omit the documentation targets and their extra dependencies.

Build goal Core packages Additional packages Make targets
Git binaries only dh-autoreconf, libcurl4-gnutls-dev, libexpat1-dev, gettext, libz-dev, libssl-dev None from the documentation list make all, then sudo make install
Binaries plus generated documentation All core packages asciidoc, xmlto, docbook2x, install-info make all doc info, then sudo make install install-doc install-html install-info

Obtain an upstream Git release

Use a tagged release tarball from the Git project’s kernel.org location or its GitHub mirror. Download the release you intend to run, then extract it. The directory name normally identifies the release, such as git-2.56.0.

For a development checkout rather than a release archive, the Git project documents cloning its repository directly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
git clone https://git.kernel.org/pub/scm/git/git.git

A checkout from the repository can contain work newer than a numbered release and is therefore a different maintenance choice. A tagged release tarball is generally easier to identify and reproduce.

Enter the extracted source directory

Change into the directory created by extraction. For the 2.56.0 release, for example:

cd git-2.56.0

If you selected another tag, use that extracted directory name instead. Run the remaining commands from this top-level source directory, where Git’s build files and configure generation rules are present.

Build and install Git without documentation

This is the shortest source build when you need the Git executables and do not need generated man pages, HTML, or Info files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Generate the configure script. Run make configure from the extracted source directory.
  2. Set the installation prefix. Run ./configure --prefix=/usr. The prefix controls where the compiled files will be installed.
  3. Compile Git. Run make all. This builds the programs but does not install them into the system.
  4. Install the result. Run sudo make install. Administrative access is needed for a system-wide installation under /usr.
make configure
./configure --prefix=/usr
make all
sudo make install

Keep the source directory until you have verified the installation. It is useful for inspecting configuration output, repeating the build, or diagnosing a failed target.

Build Git with man pages, HTML, and Info files

Install the documentation dependencies before selecting documentation targets:

sudo apt-get install asciidoc xmlto docbook2x install-info

Then run the complete documented sequence:

make configure
./configure --prefix=/usr
make all doc info
sudo make install install-doc install-html install-info

What each documentation target does

  • doc builds Git’s documentation output, including the man-page source and generated documentation where supported by the build.
  • info builds GNU Info files.
  • install-doc, install-html, and install-info copy the corresponding generated files into the installation prefix.

If one of the documentation tools is missing, the documentation phase can fail even though the core source is otherwise ready to compile. Install the complete documentation package list and rerun the command from the source directory.

Verify which Git is running

After installation, check both the reported version and the executable path:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
git --version
command -v git

For a source build based on the current Git project page, the expected release family is 2.56.0 only if you downloaded that exact tag. The version output must match the archive or checkout you selected; do not assume that installing from source automatically means the newest release.

Compare the path with the prefix you configured. With --prefix=/usr, the selected executable should resolve within the system’s normal /usr locations. If the shell still reports an older copy, inspect the path and your shell’s command lookup order before rebuilding.

When the version appears unchanged

  • Run command -v git to identify the executable actually being used.
  • Check whether another directory earlier in PATH contains Git.
  • Open a new shell if your current shell has cached a command location, then repeat both checks.
  • Confirm that the configured prefix is the one whose bin directory you are examining.

These checks distinguish a failed build from a successful installation that is being shadowed by another executable.

Use the correct workflow for Ubuntu’s packaged source

Ubuntu also documents a source-package workflow using tools such as git-ubuntu, pull-pkg, apt-get source, and dget. That workflow is for obtaining, modifying, or rebuilding Ubuntu’s packaged source and is separate from compiling an upstream release tarball.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

APT source entries are required

When using apt-get source, matching deb-src entries must be enabled in the APT sources configuration. Without source repositories configured for the relevant Ubuntu release, APT cannot retrieve the package’s source records.

Choose this route when you need Ubuntu’s packaging patches, metadata, or integration. Choose the upstream tarball route when your goal is simply to compile a tagged Git release supplied by the Git project.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and precise fixes

make configure fails immediately

Install the core dependency list, return to the source directory, and rerun:

sudo apt-get update
sudo apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
make configure

Run the command from the extracted Git top-level directory, not from its parent directory or a subdirectory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

./configure reports a missing library or header

Review the missing component named in the configure output and confirm that the corresponding development package from the core list is installed. On Ubuntu, runtime libraries and development packages are not interchangeable: compilation needs the development files.

Documentation generation fails

Install asciidoc, xmlto, docbook2x, and install-info, then rerun the documentation build:

sudo apt-get install asciidoc xmlto docbook2x install-info
make all doc info

If you do not require documentation, omit doc and info and build only with make all.

Installation fails with a permission error

A system-wide prefix such as /usr requires administrative privileges during the install phase. Re-run only the install command with sudo; compilation itself should normally run as your regular user:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo make install

For a documentation build, use the corresponding privileged install targets:

sudo make install install-doc install-html install-info

The shell still runs Ubuntu’s older Git

Check command -v git and compare the result with the configured prefix. A different directory earlier in PATH can take precedence. Correct the path order for the account or environment that needs the source-built Git, then open a new shell and verify again.

You installed the wrong release

Read the version printed by git --version and compare it with the tag or archive directory you selected. Source installation does not infer your intended release; the downloaded source determines the result.

Updating a source-built Git

A source installation does not become current through Ubuntu’s normal package updates. To move to a newer upstream release, obtain the newer tagged source, extract it into a new directory, install the dependencies if necessary, repeat the configure and build sequence, and verify the new path and version.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep a record of the tag, configure options, and documentation choice used for each build. Reusing the same prefix makes path verification especially important when a distribution-managed Git remains installed.

Source build checklist

  • Decide whether the upstream version or a custom build justifies leaving Ubuntu’s package-managed route.
  • Record the current outputs of git --version and command -v git.
  • Install the six core build dependencies.
  • Install the four documentation packages only when building documentation.
  • Obtain and extract a tagged upstream release, or clone the documented Git repository for a development checkout.
  • Run make configure and ./configure --prefix=/usr.
  • Use make all for binaries, or make all doc info for binaries plus documentation.
  • Install with the matching sudo make install command.
  • Run git --version and command -v git again to verify the result and resolve any path mismatch.

Which method should you choose?

Use Ubuntu’s package when integration, routine security updates, and minimal administration matter most. Use an upstream source build when the distribution release is behind the Git version you need or when you require control over the build. Use Ubuntu’s source-package tools when you are specifically rebuilding Ubuntu’s packaged Git rather than installing an unmodified upstream release.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.