Git:New Source Code Management System
 
 

Git is a new source code management system to be used in collaborative software development environment.
Its is quite popular these days, even Linux Kernel is now managed by git. I am giving below quick steps
to setup a remote git repository and how to add remote repository to your local git configuration.

In case, you don't have git installed on your system, visit  http://git-scm.com/download to pick the right
version of git binary or to build git on your own for your system. I would suggest to use tar.bz2 archives
compared to tar.gz, because bzip2 has higher compression ratio.

For ubuntu users, its very simple to add git to your system, just run below commands.
 sudo apt-get update
 sudo apt-get install git
 
The above commands could be different but its eqaully easy for yum, yast etc users.

Steps for setting up remote git repository
Its pretty simple connect to remote machine where you want to create the repository.

local_machine $ ssh avinesh@remote.machine
remote_machine $ cd /my_projects
remote_machine $ mkdir new_project.git
remote_machine $ cd new_project.git
remote_machine $ git --bare init
Initialized empty Git repository in /my_projects/new_project.git

Thats it!, we are done with creating remote repository.

Steps for adding the newly creating git repository to local git set-up
local_machine $ cd /home/avinesh/my_projects
local_machine $ mkdir new_project
local_machine $ cd new_project
local_machine $ git init
Initialized empty Git repository in /home/avinesh/my_projects/new_project
local_machine $ touch README ChangeLog News INSTALL

Creating list of files to commit.
local_machine $ git add README ChangeLog News INSTALL

Update the local repository with the latest changes.

local_machine $ git commit -m 'My first commit - Avinesh'

This step tells the local git setup about remote git repository.

local_machine $ git remote add origin avinesh@remote.machine:/my_projects/new_project.git

The following step pushes the changes to the remote repo.

local_machine $ git push origin master


One easy way to have the local git configured to use the remote repository is by using 'git clone'
local_machine $ git clone ssh://avinesh@remote.machine/my_projects/new_project.git
Initialized empty Git repository in /my_projects/new_project/.git/
avinesh@remote.machine's password:
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
local_machine $

In case you encounter error at any step, the first page to look for help is http://git.or.cz/gitwiki/GitFaq

To know more about git refer to pages mentioned below.

References:-
1) http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
2) http://linux.yyz.us/git-howto.html