16

I downloaded git source from https://github.com/git/git as a zip file.

I extracted it into /home/Desktop/denis/git (using Ubuntu).

Now the tutorial here says that I should run

./configure --prefix=/home/denis/git-static CFLAGS="${CFLAGS} -static"

from the above mentioned folder as a step for building git.

But the git source does not appear to have a configure file in it's root folder which I can run (only configure.ac, which I suspect is not what I'm looking for).

What am I missing here? How to build git manually?

I'm doing this because I'm trying to get git working on a shared hosting server where I'm not able to install git.

Tool
  • 12,126
  • 15
  • 70
  • 120

2 Answers2

8

The other answers did not work for me. Perhaps they will for others. What did work for me was:

  1. Get the source code
  2. Make a target directory
  3. Enter the source directory
  4. Configure
  5. Build
  6. Install

Use the following commands:

git clone git@github.com:git/git.git
mkdir git-static
cd git
./configure prefix=/path/to/git-static/ CFLAGS="${CFLAGS} -static"
make
make install

This will leave you with a few folders in the git-static directory, but the executable is statically linked. It is also substantially bigger than usual (maybe 1.5 MB bigger).

theherk
  • 6,954
  • 3
  • 27
  • 52
  • Just did it on the latest version of Raspbian (targeting an OpenWRT device) and it warned me that something would still be loaded dynamically. – Thorbjørn Ravn Andersen Oct 15 '20 at 09:04
  • 1
    @ThorbjørnRavnAndersen That's likely because you used glibc as your C library, which really doesn't support static linking at all. The best option is to use a musl "cross compiler". – diagprov Jan 30 '21 at 21:59
  • This works fine for producing static binaries (with musl as the C library). Unfortunately the remote backends (like `git-remote-https`) are not included into the git binary. Would be nice if there were some option for including these tools into the main `git` binary. – f9c69e9781fa194211448473495534 Jun 15 '21 at 19:25
-7

Read the INSTALL file in the root folder of the unzipped file, it seems there is some useful instruction in it, what I suspect:

Alternatively you can use autoconf generated ./configure script to set up install paths (via config.mak.autogen), so you can write instead

    $ make configure ;# as yourself
    $ ./configure --prefix=/usr ;# as yourself
    $ make all doc ;# as yourself
    # make install install-doc install-html;# as root

or just simply:

    $ make prefix=/usr all doc info ;# as yourself
    # make prefix=/usr install install-doc install-html install-info ;# as root
Bela Vizer
  • 2,527
  • 22
  • 26