Wednesday, 2 May 2018

Step by Step configuration of Git on linux

[root@sankar-devops ~]# yum groupinstall "Development Tools"
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.69-11.el7 will be installed
--> Processing Dependency: perl >= 5.006 for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(warnings) for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(vars) for package: autoconf-2.69-11.el7.noarch
--> Proces

[root@sankar-devops ~]#
[root@sankar-devops ~]# yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Package gettext-devel-0.19.8.1-2.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package openssl-devel.x86_64 1:1.0.2k-8.el7 will be installed
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-8.el7 for package: 1:openssl-devel-1.0.2k-8.el7.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-8.el7.x86_64
---> Package perl-CPAN.noarch 0:1.9800-292.el7 will be installed


[root@sankar-devops opt]# wget https://github.com/git/git/archive/v2.17.0.tar.gz

[root@sankar-devops opt]# ls -l
total 7204
-rw-r--r--.  1 root root 7358338 May  3 00:04 v2.17.0.tar.gz

[root@sankar-devops ~]# tar -xvzf v2.17.0.tar.gz

[root@sankar-devops opt]# ls -l
total 7204
drwxrwxr-x. 24 root root   12288 Apr  2 22:43 git-2.17.0
-rw-r--r--.  1 root root 7358338 May  3 00:04 v2.17.0.tar.gz

[root@sankar-devops opt]# cd git-2.17.0/

[root@sankar-devops git-2.17.0]# make configure
GIT_VERSION = 2.17.0
    GEN configure
[root@sankar-devops git-2.17.0]#

[root@sankar-devops git-2.17.0]# ./configure --prefix=/usr/local

[root@sankar-devops git-2.17.0]# make install

[root@sankar-devops git-2.17.0]# git --version
git version 2.17.0
[root@sankar-devops git-2.17.0]#

[root@sankar-devops git-2.17.0]# git config --global user.name "sankar"
[root@sankar-devops git-2.17.0]# git config --global user.email "sankar.kodipilla@gmail.com"
[root@sankar-devops git-2.17.0]#

[root@sankar-devops git-2.17.0]# git config --list
user.name=sankar
user.email=sankar.kodipilla@gmail.com
[root@sankar-devops git-2.17.0]#

[root@sankar-devops git-2.17.0]# useradd sangit
[root@sankar-devops git-2.17.0]#
[root@sankar-devops git-2.17.0]# su - sangit
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ ssh-keygen -t rsa -b 4096 -C "sankar.kodipilla@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sangit/.ssh/id_rsa):
Created directory '/home/sangit/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/sangit/.ssh/id_rsa.
Your public key has been saved in /home/sangit/.ssh/id_rsa.pub.
The key fingerprint is:
96:31:83:fe:dd:47:d9:9d:3c:3e:2b:47:50:3b:18:ce sankar.kodipilla@gmail.com
The key's randomart image is:
+--[ RSA 4096]----+
|                 |
|       .     . . |
|      . +   o + .|
|     .   =   E.=o|
|      . S     +++|
|       o . . ....|
|        . . . oo |
|             o .o|
|              o. |
+-----------------+
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ eval "$(ssh-agent -s)"
Agent pid 3089
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ ssh-add ~/.ssh/id_rsa
Identity added: /home/sangit/.ssh/id_rsa (/home/sangit/.ssh/id_rsa)
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCz4kZba0TlsMhe2vut7QQfg/vBH8T5GGNGImlnFh0dMJ5b9JgEuj0kE6IdB9J/68TeO2DjWO6kfiP6Qi07bTsGpybAck+VtVEwY+FsrTYURJPgLkdJkK6zFAy1BQJ8vq/qE7nkpIG+l9su4v8WExSFNoTZMGO2NO7JHcaakBvn3IWh1+nO1TooK9/7g7VdJvAEX2/m276Fhu1JDxu3mlyis1SYBv8yUGp5wSDB89KLPb*************************== sankar.kodipilla@gmail.com
[sangit@sankar-devops ~]$


[sangit@sankar-devops ~]$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is 16:27:ac:44::63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Hi sankar-kodipilla! You've successfully authenticated, but GitHub does not provide shell access.
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ git init
Initialized empty Git repository in /home/sangit/.git/
[sangit@sankar-devops ~]$


[sangit@sankar-devops ~]$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .bash_logout
        .bash_profile
        .bashrc
        .ssh/

nothing added to commit but untracked files present (use "git add" to track)
[sangit@sankar-devops ~]$


[sangit@sankar-devops ~]$ cat > gittest_file1.txt
test1

[sangit@sankar-devops ~]$ cat > gittest_file2.txt
test2 


[sangit@sankar-devops ~]$ pwd
/home/sangit
[sangit@sankar-devops ~]$ ll
total 8
-rw-rw-r--. 1 sangit sangit 6 May  3 01:19 gittest_file1.txt
-rw-rw-r--. 1 sangit sangit 7 May  3 01:19 gittest_file2.txt
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .bash_logout
        .bash_profile
        .bashrc
        .ssh/
        gittest_file1.txt
        gittest_file2.txt

nothing added to commit but untracked files present (use "git add" to track)
[sangit@sankar-devops ~]$


[sangit@sankar-devops ~]$ git add -A
[sangit@sankar-devops ~]$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   .bash_logout
        new file:   .bash_profile
        new file:   .bashrc
        new file:   .ssh/id_rsa
        new file:   .ssh/id_rsa.pub
        new file:   .ssh/known_hosts
        new file:   gittest_file1.txt
        new file:   gittest_file2.txt

[sangit@sankar-devops ~]$


Error:

[sangit@sankar-devops ~]$ git commit -m "adding two files"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <sangit@sankar-devops.AS.Domcorp.Zetainteractive.com>) not allowed


[sangit@sankar-devops ~]$ git config --global user.name "sangit"

[sangit@sankar-devops ~]$ git commit -m "adding two files"
[master (root-commit) b2b6031] adding two files
 Committer: sangit <sangit@sankar-devops.AS.Domcorp.Zetainteractive.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

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 8 files changed, 81 insertions(+)
 create mode 100644 .bash_logout
 create mode 100644 .bash_profile
 create mode 100644 .bashrc
 create mode 100644 .ssh/id_rsa
 create mode 100644 .ssh/id_rsa.pub
 create mode 100644 .ssh/known_hosts
 create mode 100644 gittest_file1.txt
 create mode 100644 gittest_file2.txt
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ git commit -a
On branch master
Untracked files:
        .gitconfig

nothing added to commit but untracked files present
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ ls -l
total 8
-rw-rw-r--. 1 sangit sangit 6 May  3 01:19 gittest_file1.txt
-rw-rw-r--. 1 sangit sangit 7 May  3 01:19 gittest_file2.txt
[sangit@sankar-devops ~]$ cat > gittest_file3.txt
test3
^C 
[sangit@sankar-devops ~]$ cat > gittest_file4.txt
test4
^C
[sangit@sankar-devops ~]$ ls -l
total 16
-rw-rw-r--. 1 sangit sangit 6 May  3 01:19 gittest_file1.txt
-rw-rw-r--. 1 sangit sangit 7 May  3 01:19 gittest_file2.txt
-rw-rw-r--. 1 sangit sangit 6 May  3 01:47 gittest_file3.txt
-rw-rw-r--. 1 sangit sangit 6 May  3 01:47 gittest_file4.txt
[sangit@sankar-devops ~]$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitconfig
        gittest_file3.txt
        gittest_file4.txt

nothing added to commit but untracked files present (use "git add" to track)
[sangit@sankar-devops ~]$

[sangit@sankar-devops ~]$ git add  gittest_file3.txt
[sangit@sankar-devops ~]$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   gittest_file3.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitconfig
        gittest_file4.txt

[sangit@sankar-devops ~]$ git commit -a -m "adding more files"
[master 71a2fdb] adding more files
 Committer: sangit <sangit@sankar-devops.AS.Domcorp.Zetainteractive.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

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 gittest_file3.txt
[sangit@sankar-devops ~]$


[sangit@sankar-devops ~]$ git remote add origin "https://github.com/sankar-kodipilla/sangit"
[sangit@sankar-devops ~]$

1 comment: