GIT is the most versatile distributed version control system.
Installation:
yum install git
[root@rhel_client ~]# yum install git
Loaded plugins: product-id, subscription-manager
Updating Red Hat repositories.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.i686 0:1.7.1-2.el6_0.1 will be installed
--> Processing Dependency: perl-Git = 1.7.1-2.el6_0.1 for package: git-1.7.1-2.el6_0.1.i686
--> Processing Dependency: perl(Error) for package: git-1.7.1-2.el6_0.1.i686
--> Processing Dependency: perl(Git) for package: git-1.7.1-2.el6_0.1.i686
--> Running transaction check
---> Package perl-Error.noarch 1:0.17015-4.el6 will be installed
---> Package perl-Git.noarch 0:1.7.1-2.el6_0.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
git i686 1.7.1-2.el6_0.1 sabitha 4.5 M
Installing for dependencies:
perl-Error noarch 1:0.17015-4.el6 sabitha 29 k
perl-Git noarch 1.7.1-2.el6_0.1 sabitha 28 k
Transaction Summary
================================================================================
Install 3 Package(s)
Total download size: 4.6 M
Installed size: 15 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): git-1.7.1-2.el6_0.1.i686.rpm | 4.5 MB 00:00
(2/3): perl-Error-0.17015-4.el6.noarch.rpm | 29 kB 00:00
(3/3): perl-Git-1.7.1-2.el6_0.1.noarch.rpm | 28 kB 00:00
--------------------------------------------------------------------------------
Total 29 MB/s | 4.6 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:perl-Error-0.17015-4.el6.noarch 1/3
Installing : git-1.7.1-2.el6_0.1.i686 2/3
Installing : perl-Git-1.7.1-2.el6_0.1.noarch 3/3
duration: 557(ms)
Installed products updated.
Installed:
git.i686 0:1.7.1-2.el6_0.1
Dependency Installed:
perl-Error.noarch 1:0.17015-4.el6 perl-Git.noarch 0:1.7.1-2.el6_0.1
Complete!
[root@rhel_client ~]#
2) ADD user git
[root@rhel_client ~]# useradd git
[root@rhel_client ~]# passwd git
3)[root@rhel_client ~]# sudo su git
[git@rhel_client root]$ cd ~
[git@rhel_client ~]$ ls
[git@rhel_client ~]$ git config --global user.name "git"
[git@rhel_client ~]$ git config --global user.email "git@sabitha.com"
[git@rhel_client ~]$ mkdir test
[git@rhel_client test]$ pwd
/home/git/test
[git@rhel_client test]$ git --bare init
Initialized empty Git repository in /home/git/test/
[git@rhel_client test]$ ls -ltrh
total 32K
drwxrwxr-x 4 git git 4.0K Feb 25 10:47 refs
drwxrwxr-x 2 git git 4.0K Feb 25 10:47 info
drwxrwxr-x 2 git git 4.0K Feb 25 10:47 branches
drwxrwxr-x 2 git git 4.0K Feb 25 10:47 hooks
-rw-rw-r-- 1 git git 23 Feb 25 10:47 HEAD
-rw-rw-r-- 1 git git 73 Feb 25 10:47 description
-rw-rw-r-- 1 git git 66 Feb 25 10:47 config
drwxrwxr-x 4 git git 4.0K Feb 25 10:47 objects
[git@rhel_client test]$
Client side:
Cloning repo
[sabitha@rhel_client ~]$ git clone git@192.168.0.16:test
Initialized empty Git repository in /home/sabitha/test/.git/
git@192.168.0.16's password:
warning: You appear to have cloned an empty repository.
Adding file
[sabitha@rhel_client test]$ git add .
[sabitha@rhel_client test]$ touch samp1
[sabitha@rhel_client test]$ git commit -am "samp1 file created"
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# samp1
nothing added to commit but untracked files present (use "git add" to track)
[sabitha@rhel_client test]$
git push --set-upstream origin master
git status
[sabitha@rhel_client test]$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# samp1
nothing added to commit but untracked files present (use "git add" to track)
[sabitha@rhel_client test]$
git push
[sabitha@rhel_client test]$ git push -u origin master
git@192.168.0.16's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 213 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.0.16:test
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
[sabitha@rhel_client test]$
git branch
[sabitha@rhel_client test]$ git branch -a
* master
remotes/origin/master
[sabitha@rhel_client test]$
git pull
[sabitha@rhel_client test]$ git pull
git@192.168.0.16's password:
Already up-to-date.
[sabitha@rhel_client test]$
Remote:
git remote add origin https://github.com/try-
git/try_git.git
Adding more files
[sabitha@rhel_client test]$ touch samp2
[sabitha@rhel_client test]$ git add samp2
[sabitha@rhel_client test]$ git commit -am "Added samp2 file"
[master 25033ae] Added samp2 file
Committer: sabitha <sabitha@rhel_client.sabitha.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <you@example.com>'
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 samp2
[sabitha@rhel_client test]$ git push
git@192.168.0.16's password:
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 238 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@192.168.0.16:test
a79e50e..25033ae master -> master
[sabitha@rhel_client test]$
[sabitha@rhel_client test]$ git checkout
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commit(s) each, respectively.
[sabitha@rhel_client test]$
Git branch created
[sabitha@rhel_client test]$ git branch test
[sabitha@rhel_client test]$ git branch -a
* master
test
remotes/origin/master
[sabitha@rhel_client test]$
git merge
git merge test
git deleting branch
git branch -d <branch name>