Installing Git on Linux and setting up the server

For CentOS/Fedora:

yum install git

For Ubuntu/Debian:

apt-get install git


Install Git from the source
It is generally a good idea to install it from the source because you’ll get the most recent version.

Prior to installing Git itself, download all of the required dependancies:

yum install curl-devel expat-devel gettext-devel \ openssl-devel zlib-devel

apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \ libz-dev libssl-dev

Grab the latest Git source from the Git web site

http://git-scm.com/download

Untar the file and switch into that directory

tar -zxf git-1.7.2.2.tar.gz
cd git-1.7.2.2

Then install

make prefix=/usr/local all
sudo make prefix=/usr/local install

If you need to update Git in the future, you can use Git itself to do it.

git clone git://git.kernel.org/pub/scm/git/git.git

Set your user name and e-mail address

git config --global user.name "Your name"
git config --global user.email email@domain.com

You can see all of your settings with this command

git config --list

To Create an empty remote Git repository

mkdir my_project.git
cd project.git
git --bare init

Using your Git Server from your Local Computer

cd my_project
git init
git add *
git commit -m "My initial commit message"
git remote add origin git@example.com:my_project.git
git push -u origin master

Team members can now clone and track the remote repository using the following:

git clone git@example.com:my_project.git
cd my_project

One Comment on “Installing Git on Linux and setting up the server

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>