≡ Menu

Debian / Ubuntu Linux: HowTo Download A Git Repository

I would like to install something from source code. The site says that I need to download it from git repository. How do I download a git repository under a Debian / Ubuntu Linux?

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals. You need to install git and git-core packages under a Debian or Ubuntu Linux.

In this quick tutorial you will learn how to clone a git repo and compile software on your local GNU/Linux system.


Type the following apt-get command to install the same:
# apt-get install git git-core
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-75 linux-headers-3.2.0-77 linux-headers-3.2.0-77-virtual
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run git-daemon-sysvinit git-doc git-el git-arch git-cvs git-svn
  git-email git-gui gitk gitweb
The following NEW packages will be installed:
  git git-core git-man liberror-perl
0 upgraded, 4 newly installed, 0 to remove and 2 not upgraded.
Need to get 6,752 kB of archives.
After this operation, 15.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrors.service.networklayer.com/ubuntu/ precise/main liberror-perl all 0.17-1 [23.8 kB]
Get:2 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main git-man all 1: [631 kB]
Get:3 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main git amd64 1: [6,097 kB]
Get:4 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main git-core all 1: [1,380 B]
Fetched 6,752 kB in 0s (25.2 MB/s)
Selecting previously unselected package liberror-perl.
(Reading database ... 223212 files and directories currently installed.)
Unpacking liberror-perl (from .../liberror-perl_0.17-1_all.deb) ...
Selecting previously unselected package git-man.
Unpacking git-man (from .../git-man_1%3a1.7.9.5-1ubuntu0.1_all.deb) ...
Selecting previously unselected package git.
Unpacking git (from .../git_1%3a1.7.9.5-1ubuntu0.1_amd64.deb) ...
Selecting previously unselected package git-core.
Unpacking git-core (from .../git-core_1%3a1.7.9.5-1ubuntu0.1_all.deb) ...
Processing triggers for man-db ...
Setting up liberror-perl (0.17-1) ...
Setting up git-man (1: ...
Setting up git (1: ...
Setting up git-core (1: ...


The syntax is as follows:

git clone git://server1.cyberciti.biz/path/to/project

In this example I’m going to clone emerald so that I can build it locally:
$ cd ~/buildtests
$ git clone git://anongit.compiz.org/fusion/decorators/emerald

Sample outputs:

Cloning into emerald...
remote: Counting objects: 2272, done.
remote: Compressing objects: 100% (2221/2221), done.
remote: Total 2272 (delta 1622), reused 0 (delta 0)
Receiving objects: 100% (2272/2272), 859.78 KiB | 255 KiB/s, done.
Resolving deltas: 100% (1622/1622), done.

cd into emerald and list the files, enter:
$ cd emerald
$ ls -l

Sample outputs:

total 124
-rw-r--r-- 1 vivek vivek  1903 Jul 18 23:29 AUTHORS
-rwxr-xr-x 1 vivek vivek   261 Jul 18 23:29 autogen.sh
-rw-r--r-- 1 vivek vivek    21 Jul 18 23:29 ChangeLog
-rw-r--r-- 1 vivek vivek  2438 Jul 18 23:29 configure.ac
-rw-r--r-- 1 vivek vivek 18002 Jul 18 23:29 COPYING
drwxr-xr-x 3 vivek vivek  4096 Jul 18 23:29 defaults
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 doc
-rw-r--r-- 1 vivek vivek 15590 Jul 18 23:29 emerald.po
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 engines
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 include
-rw-r--r-- 1 vivek vivek  9498 Jul 18 23:29 INSTALL
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 libengine
-rw-r--r-- 1 vivek vivek   259 Jul 18 23:29 Makefile.am
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 misc
-rw-r--r-- 1 vivek vivek    31 Jul 18 23:29 NEWS
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 pixmaps
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 po
-rw-r--r-- 1 vivek vivek   276 Jul 18 23:29 README
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 src
drwxr-xr-x 2 vivek vivek  4096 Jul 18 23:29 themer
-rw-r--r-- 1 vivek vivek   261 Jul 18 23:29 TODO
-rw-r--r-- 1 vivek vivek    14 Jul 18 23:29 VERSION

You just cloned emerald from from Git to your local machine. You can make modifications and push changes, or just build the software:
$ ./configure --options
$ make
$ sudo make install

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 2 comments… add one }
  • Oleg July 27, 2012, 8:52 am

    Useless article whithout describing howto:
    >You can make modifications and push changes, or just build the software.
    “git clone” already decribed almost on every open source software homepage.

    And not «just build», but *properly* for Ubuntu/Debian build and install.

  • Bob June 22, 2016, 7:35 am

    You skipped the most important part :/ this is useless

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , ,