I’m sure there are tons of blogs out there on the same subject. This is just like a reference for me and others out there who might stumble upon this post. Note that what I have documented here is what worked for me. At the time of writing the latest GIT version was 1.7.1
- First we install the dependent packages, thus you wont have to install the packages yourself.
- Download latest stable GIT release from here
- Extract the archive and change to the extracted directory
- Run the following
- Check installation and clean up
$ sudo aptitude build-dep git-core
$ wget http://kernel.org/pub/software/scm/git/git-1.7.1.tar.gz
# tar xvzf git-1.7.1.tar.gz
# cd git-1.7.1/
$ ./configure
$ make
$ sudo make install
$ git --version
$ cd ../;rm -r git-1.7.1 git-1.7.1.tar.gz




Simple and concise. Thanks for this post.
Hi Kibet. I really like your blog. I am having some problems with your git how to. I am using a Lucid minimal install. I get this error when trying to make the package.
terry@ubuntu:~/git-1.7.1$ make
CC fast-import.o
In file included from builtin.h:6,
from fast-import.c:147:
cache.h:17:18: error: zlib.h: No such file or directory
In file included from builtin.h:6,
from fast-import.c:147:
cache.h:22: error: expected ‘)’ before ‘strm’
cache.h:23: error: expected ‘)’ before ‘strm’
cache.h:24: error: expected ‘)’ before ‘strm’
fast-import.c:285: error: ‘Z_DEFAULT_COMPRESSION’ undeclared here (not in a function)
fast-import.c: In function ‘store_object’:
fast-import.c:996: error: ‘z_stream’ undeclared (first use in this function)
fast-import.c:996: error: (Each undeclared identifier is reported only once
fast-import.c:996: error: for each function it appears in.)
fast-import.c:996: error: expected ‘;’ before ‘s’
fast-import.c:1028: error: ‘s’ undeclared (first use in this function)
fast-import.c:1039: error: ‘Z_FINISH’ undeclared (first use in this function)
fast-import.c:1039: error: ‘Z_OK’ undeclared (first use in this function)
fast-import.c: In function ‘stream_blob’:
fast-import.c:1142: error: ‘z_stream’ undeclared (first use in this function)
fast-import.c:1142: error: expected ‘;’ before ‘s’
fast-import.c:1143: error: ‘Z_OK’ undeclared (first use in this function)
fast-import.c:1165: error: ‘s’ undeclared (first use in this function)
fast-import.c:1175: error: ‘Z_STREAM_END’ undeclared (first use in this function)
fast-import.c:1188: error: ‘Z_FINISH’ undeclared (first use in this function)
fast-import.c:1200: error: ‘Z_BUF_ERROR’ undeclared (first use in this function)
fast-import.c: In function ‘git_pack_config’:
fast-import.c:2846: error: ‘Z_BEST_COMPRESSION’ undeclared (first use in this function)
make: *** [fast-import.o] Error 1
Hi Terry, looking at the error message you got it seems that you are missing the zlib compression package needed by git.
I’m assuming you did first install the dependent packages. If so, just do a
$ sudo aptitude install zlib1g-dev.After that you should be fine.
I was also missing tk but after a quick search of google I found gits dependencies and made sure I had everything.
Thank you and keep up the great work.
Thank you Terry, Ivan. Glad to hear that this helped someone out there.
Thank you very much.
It helped a lot indeed.
Everything went as you said.
Wow… very easy .. thanks
Simple and easy for understanding. Thanks for your work.
I had to use sudo for all these commands.
I use ubuntu.
Why so?
Should i create a new user for this and set some permissions ?
If so, what are the steps ?
thanks
Hi gitfan,
The reason why you have to use sudo is because the installation process needs to copy files to folders which are only writable to the root user or another user who has write permissions to these folders. The only other way not to use sudo is if the current user has the write permissions to these folders or you are logged in as root. So this also answers your second question. Creating another user solely for installing git? no, not necessary. ‘sudo’ is there just for these administrative tasks, so you wont have to log in as the superuser or root every time you need to install, or do anything that needs superuser privileges.
Hi,
I’m newbee to git.. Please help me configuring git with apache on ubuntu 10.04. so i can access my git through apache
Thanks,
Gulab Pasha
@Gulab,
Your question is rather vague, are you talking about setting a git web interface, if so, try using gitweb, i found this and this look promising.
Hi I have a big problem with ubuntu 10.04 I am new in git and i would like to run the git daemon server.
I have my git repository and i can watch it with git instaweb ( lighttpd already isntalled )
the instructions in order to do that were:
(server)$ touch /git/project.git/git-daemon-export-ok
(server)$ sudo apt-get install xinetd
(server)$ sudo vi /etc/xinetd.d/git
service git
{
disable = no
type = UNLISTED
port = 9418
socket_type = stream
wait = no
user = nobody
server = /usr/bin/git-daemon
server_args = –inetd –export-all –base-path=/git
}
(server)$ sudo /etc/init.d/xinetd restart
This now gives us a public git repository url we can distribute to others.
(client)$ git clone git://server/project.git
but i Don’t have the /usr/bin/git-daemon in my computer any idea ?? please help me
Thanks
VIctor
The latest stable release of Git is always packaged in the git-core PPA for all versions of Ubuntu, so you don’t need to build it yourself.
Just run
sudo add-apt-repository ppa:git-core/ppa
sudo aptitude update
sudo aptitude full-upgrade
Aaaah this is what I was looking for. Don’t want to build stuff on my live server, just deploy the pre-packaged ubuntu pkgs. Thanks Andreas!
The commands I ran to get the pre-packaged PPA (http://launchpad.net/git/) git working on a new 10.04 system were:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:git-core/ppa
sudo aptitude update
sudo aptitude safe-upgrade
sudo aptitude install git
Thanks so much lantrix, that’s exactly what I needed (Rackspace Cloud, Ubuntu 10.04). Much more useful than the main article!
I happen to use Ubuntu on Rackspace too, to be specific Slicehost.
Hey i finally could find the solution to my problem
here is the ubuntu forum in order to check i described as much as i could
thanks kibyegon for your help this tutorial help me a lot in the beginning
http://ubuntuforums.org/showthread.php?p=9645200#post9645200
Thanks for all
Sincerely yours
Victor Rodriguez
Great blog. Simple and concise.
Thank you!
This was helpful
Hi. Why are you installing both from source and the deb package git-core?
@Jose, the reason why you install git-core from deb repository is because git-core provides the primary components of git. If I only install git from source, it wouldn’t work because git as an application requires certain capabilities which git source you get from the git website wouldn’t give you. There are other git applications such as git-arch, git-svn and git-arch which use the primary git package ‘git-core’ as their base. If you do not want to get yourself dirty with installing from source, There are pretty recent packaged git binaries for you, thanks to Anders Karseorg. Just check out his comments on this same post.
Thanks a lot sir for perfect article. It was really useful for me.
Hi,
I’m newbee to git.. I was trying to install git in ubuntu 10.04 .
Can you tell me why these type error going on here ..
rokon@rokon-laptop:~/git-1.7.1$ ./configure
./configure: line 1507: config.log: Permission denied
./configure: line 1517: config.log: Permission denied
rokon@rokon-laptop:~/git-1.7.1$ make
CC fast-import.o
In file included from builtin.h:4,
from fast-import.c:147:
git-compat-util.h:140:25: error: openssl/ssl.h: No such file or directory
git-compat-util.h:141:25: error: openssl/err.h: No such file or directory
In file included from builtin.h:6,
from fast-import.c:147:
cache.h:9:21: error: openssl/sha.h: No such file or directory
In file included from fast-import.c:156:
csum-file.h:10: error: expected specifier-qualifier-list before ‘SHA_CTX’
fast-import.c: In function ‘store_object’:
fast-import.c:995: error: ‘SHA_CTX’ undeclared (first use in this function)
fast-import.c:995: error: (Each undeclared identifier is reported only once
fast-import.c:995: error: for each function it appears in.)
fast-import.c:995: error: expected ‘;’ before ‘c’
fast-import.c:1000: warning: implicit declaration of function ‘SHA1_Init’
fast-import.c:1000: error: ‘c’ undeclared (first use in this function)
fast-import.c:1001: warning: implicit declaration of function ‘SHA1_Update’
fast-import.c:1003: warning: implicit declaration of function ‘SHA1_Final’
fast-import.c: At top level:
fast-import.c:1118: error: expected declaration specifiers or ‘…’ before ‘SHA_CTX’
fast-import.c: In function ‘truncate_pack’:
fast-import.c:1126: error: ‘struct sha1file’ has no member named ‘total’
fast-import.c:1128: error: ‘struct sha1file’ has no member named ‘ctx’
fast-import.c:1128: error: ‘ctx’ undeclared (first use in this function)
fast-import.c: In function ‘stream_blob’:
fast-import.c:1140: error: ‘SHA_CTX’ undeclared (first use in this function)
fast-import.c:1140: error: expected ‘;’ before ‘c’
fast-import.c:1141: error: expected ‘;’ before ‘pack_file_ctx’
fast-import.c:1154: error: ‘pack_file_ctx’ undeclared (first use in this function)
fast-import.c:1154: error: ‘struct sha1file’ has no member named ‘ctx’
fast-import.c:1160: error: ‘c’ undeclared (first use in this function)
fast-import.c:1220: error: too many arguments to function ‘truncate_pack’
fast-import.c:1227: error: too many arguments to function ‘truncate_pack’
make: *** [fast-import.o] Error 1
rokon@rokon-laptop:~/git-1.7.1$
You probably need to run the commands as root. Just type ‘sudo -s’ if you are running ubuntu which gives you root previlages. If you are running another distro just switch to root and you’ll be fine.
found a more detailed how-to:
http://distriwatch.de/2010/08/how-to-installation-git-repository-on-ubuntu-10-04/
Hi Kibyegon. I followed the install instructions posted here, everything seemed to go as expected. My version is git version 1.7.3.1. But non of the manual pages are installed. For every git
help COMMAND, I get nothing. Example : git$ git help add
No manual entry for git-add
See ‘man 7 undocumented’ for help when manual pages are not available. I installed this git release on my new ubuntu 10.04 desktop. I’ve missed something, but I’m not sure what.
There are different ways of getting the git man pages. this will probably help you out. http://www.codeography.com/2009/09/15/install-git-man-pages-the-easy-way.html
Great blog, thanks. However, for me it actually seems to work just typing
sudo apt-get install git
This is actually the default explanation that comes up if you try to write ‘git’ at the command prompt in Meerkat.
Wouldn’t it be git-core?
Thanks for this post. It is just the best. Simple and concise with no additional stuffs.
thanks Akinyele
sir i got such result $ sudo aptitude install zlib1g-dev
sudo: aptitude: command not found
what should i do………
Hi Guys,
Is there anyway we can install trac with git.
Thx
You just made my day! Getting git up and running was the last obstacle to developing on my new Ubuntu laptop. Thank you. These instructions worked like a charm.
exactly what I was looking for, and very easy to follow. Thanks!
If you interested in running the latest stable release of git on Ubuntu 10.10 or Ubuntu 10.04, it is available in a Launchpad repository. For more instructions: http://blog.avirtualhome.com/git-packages-for-ubuntu/
For debian lenny add backports to your apt sources:
nano /etc/apt/sources.list
add: deb http://www.backports.org/debian lenny-backports main contrib
apt-get update
apt-get -t lenny-backports install git
This will install the latest backport- the standard lenny package is 1.5, I needed 1.7
simple and easy.thanks
[...] ffmpeg find, press enter to download by git 但是apt-get git各种不能, 于是参考: How to install Git on Ubuntu Lucid (10.04) 然后继续configure, 跑了一半说: Error: X11 support required for GUI compilation [...]
Thank you!
now off to check out more of your blog.
Many thanks. It is the shortest and as such better guide to install Git. Up to date Git version is 1.7.5.1
Hi,
I’m new at this Linux stuff so sorry for the simple question.
Just tried installing GIT 1.7.5.1 from here:
http://git-scm.com/download
I typed “make” in a terminal shell, per the instructions, and I get an error about not finding zlib.h. where do it get zlib.h? It was not included in the download
Thanks!
Hello Mark,
That kind of error is always caused by some missing libraries. Please check my reply to @Terry’s comment.
Thanks a lot. It worked…. great.
Thanks man, very easy to follow!
hi,
I’ want download a driver :
http://www.backtrack-linux.org/forums/hardware-compatibility-list/32897-broadcom-bcm43225-%5B14e4-4357%5D-not-working.html
with git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-next-2.6.git
but when i write :
me@me-laptop:~$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-next-2.6.git
Initialized empty Git repository in /home/lefrancois/staging-next-2.6/.git/
fatal: The remote end hung up unexpectedly
why unexpectedly, there is a peapol have found this problems?
For Ubuntu 10.04 with Git version 1.7.6 run the following before step 5:
$ sudo apt-get install zlib1g-dev libssl-dev
Thanks, This is very useful and very easy way to install and use GIT
Regards
Harvin
Nice and easy way, but if you that type of person who values security, you need to set up public and private keys first (of course using OpenSSH). check this out https://help.ubuntu.com/community/SSH/OpenSSH/Keys#Generating+RSA+Keys
Also if you are wanting a nice way to manage your git project, then have a look at the official Ubuntu git community page. https://help.ubuntu.com/community/Git . Best!
thanks! this help out a lot. no issues with the install in ubuntu on a rackspace cloud server.
The steps are easy to follow. I just installed 1.7.6 version of git on Ubuntu (10.10).
Thanks,
Raji
I am using svn server, now want to switch to git server, there is any idea,how to do that?
Nand
Great blog. Keep up the great work. It was just the answer I was looking for. I am working with StackOps and need git for a few new things.
The first command in your blog worked fine.
The second wget command tells me the error 503 the service is temporarily unavailable!
Is there another place to get git from?
A
Is there another place to get git from?
A
Thank you dud. Had to install it manually and this article/post is whan I needed. And I like this kind of KISS articles (keep it small and simple).
the second wget is giving a 404. I’ve tried 1.7.1, 6, and 7 (current is 1.7.7) to no avail. Perhaps someone smarter than me knows an alternate? or can help me figure out what the right filename is?
found it!
http://git-core.googlecode.com/files/git-1.7.7.1.tar.gz
[...] here is a guide to install git… How to install Git on Ubuntu Lucid (10.04) Kibet's Brain Leaks [...]
[...] – – http://blog.agdunn.net/?p=277 http://kibyegon.wordpress.com/2010/05/13/how-to-install-git-on-ubuntu-lucid-10-04/ แบ่งปัน:FacebookTwitterLike this:LikeBe the first to like this [...]
Glad you like it. Thanks
Seems like “soodaNoff” is a spam bot
PS: Is there not git package for 10.04 LTS?!
I guess askimet isn’t bullet proof. I never realized that there were more of the same comments from that bot only that they each link to a different site. Thanks for pointing this out.