Git Quick Start

github-git-cheat-sheet

gitcs_1475526882

[root@ansible ~]# yum install epel-release -y

[root@ansible ~]# yum install git -y

[root@ansible ~]# git –version
git version 1.8.3.1

[root@ansible ~]# git help
usage: git [–version] [–help] [-c name=value]
[–exec-path[=<path>]] [–html-path] [–man-path] [–info-path]
[-p|–paginate|–no-pager] [–no-replace-objects] [–bare]
[–git-dir=<path>] [–work-tree=<path>] [–namespace=<name>]
<command> [<args>]

The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty Git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG

‘git help -a’ and ‘git help -g’ lists available subcommands and some
concept guides. See ‘git help <command>’ or ‘git help <concept>’
to read about a specific subcommand or concept.
[root@ansible ~]# useradd mshaik
[root@ansible ~]# passwd mshaik
Changing password for user mshaik.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.

[root@ansible ~]# su – mshaik
Last login: Sun May 14 18:11:25 IST 2017 on pts/0
[mshaik@ansible ~]$

[mshaik@ansible ~]$ which vim
/bin/vim
[mshaik@ansible ~]$ git config –system core.editor “/bin/vim”
error: could not lock config file /etc/gitconfig: Permission denied

[mshaik@ansible ~]$ sudo git config –system core.editor “/bin/vim”

[mshaik@ansible ~]$ cat /etc/gitconfig
[core]
editor = /bin/vim

[mshaik@ansible ~]$ git config –global user.name rafi494
[mshaik@ansible ~]$ git config –global user.email mohammedrafi494@gmail.com
[mshaik@ansible ~]$ ls -la
total 24
drwx——. 3 mshaik mshaik 4096 Jun 2 01:09 .
drwxr-xr-x. 8 root root 83 May 21 17:07 ..
drwxrwxr-x 2 mshaik mshaik 37 May 15 00:21 .aws
-rw——-. 1 mshaik mshaik 113 May 14 19:55 .bash_history
-rw-r–r–. 1 mshaik mshaik 18 Nov 20 2015 .bash_logout
-rw-r–r–. 1 mshaik mshaik 193 Nov 20 2015 .bash_profile
-rw-r–r–. 1 mshaik mshaik 231 Nov 20 2015 .bashrc
-rw-rw-r– 1 mshaik mshaik 58 Jun 2 01:09 .gitconfig

[mshaik@ansible ~]$ cat .gitconfig
[user]
name = rafi494
email = mohammedrafi494@gmail.com

[mshaik@ansible ~]$ mkdir repo
[mshaik@ansible ~]$ cd repo/
[mshaik@ansible repo]$ ls -la
total 4
drwxrwxr-x 2 mshaik mshaik 6 Jun 2 01:22 .
drwx——. 4 mshaik mshaik 4096 Jun 2 01:22 ..

[mshaik@ansible repo]$ git init .
Initialized empty Git repository in /home/mshaik/repo/.git/
[mshaik@ansible repo]$ ls -la
total 4
drwxrwxr-x 3 mshaik mshaik 17 Jun 2 01:23 .
drwx——. 4 mshaik mshaik 4096 Jun 2 01:22 ..
drwxrwxr-x 7 mshaik mshaik 111 Jun 2 01:23 .git
[mshaik@ansible repo]$ ls -la .git/
total 16
drwxrwxr-x 7 mshaik mshaik 111 Jun 2 01:23 .
drwxrwxr-x 3 mshaik mshaik 17 Jun 2 01:23 ..
drwxrwxr-x 2 mshaik mshaik 6 Jun 2 01:23 branches
-rw-rw-r– 1 mshaik mshaik 92 Jun 2 01:23 config
-rw-rw-r– 1 mshaik mshaik 73 Jun 2 01:23 description
-rw-rw-r– 1 mshaik mshaik 23 Jun 2 01:23 HEAD
drwxrwxr-x 2 mshaik mshaik 4096 Jun 2 01:23 hooks
drwxrwxr-x 2 mshaik mshaik 20 Jun 2 01:23 info
drwxrwxr-x 4 mshaik mshaik 28 Jun 2 01:23 objects
drwxrwxr-x 4 mshaik mshaik 29 Jun 2 01:23 refs

####################################################################

[mshaik@ansible repo]$ echo “This is a Readme file” > README.MD
[mshaik@ansible repo]$ echo “/* This is a readme file*/” > source.c
[mshaik@ansible repo]$ ls -la
total 12
drwxrwxr-x 3 mshaik mshaik 48 Jun 2 01:30 .
drwx——. 4 mshaik mshaik 4096 Jun 2 01:22 ..
drwxrwxr-x 7 mshaik mshaik 111 Jun 2 01:23 .git
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 01:29 README.MD
-rw-rw-r– 1 mshaik mshaik 27 Jun 2 01:30 source.c
[mshaik@ansible repo]$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# README.MD
# source.c
nothing added to commit but untracked files present (use “git add” to track)

[mshaik@ansible repo]$ git add .

[mshaik@ansible repo]$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use “git rm –cached <file>…” to unstage)
#
# new file: README.MD
# new file: source.c
#

[mshaik@ansible repo]$ echo “Test file” > file1

[mshaik@ansible repo]$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use “git rm –cached <file>…” to unstage)
#
# new file: README.MD
# new file: source.c
#
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# file1

[mshaik@ansible repo]$ git add file1

[mshaik@ansible repo]$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use “git rm –cached <file>…” to unstage)
#
# new file: README.MD
# new file: file1
# new file: source.c
#

[mshaik@ansible repo]$ git commit -m “this is my first commit”
[master (root-commit) d1ce129] this is my first commit
3 files changed, 3 insertions(+)
create mode 100644 README.MD
create mode 100644 file1
create mode 100644 source.c

[mshaik@ansible repo]$ git status
# On branch master
nothing to commit, working directory clean

[mshaik@ansible repo]$ cat >> README.MD
this is newly added data

[mshaik@ansible repo]$ git status
# On branch master
# Changes not staged for commit:
# (use “git add <file>…” to update what will be committed)
# (use “git checkout — <file>…” to discard changes in working directory)
#
# modified: README.MD
#
no changes added to commit (use “git add” and/or “git commit -a”)

[mshaik@ansible repo]$ echo “This is second file in repo” > file2

[mshaik@ansible repo]$ git status
# On branch master
# Changes not staged for commit:
# (use “git add <file>…” to update what will be committed)
# (use “git checkout — <file>…” to discard changes in working directory)
#
# modified: README.MD
#
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# file2
no changes added to commit (use “git add” and/or “git commit -a”)

[mshaik@ansible repo]$ git commit -a
saving changes to README.MD
# Please enter the commit message for your changes. Lines starting
# with ‘#’ will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use “git reset HEAD <file>…” to unstage)
#
# modified: README.MD
#
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# file2

[master 9679830] saving changes to README.MD
1 file changed, 1 insertion(+)

[mshaik@ansible repo]$ git status
# On branch master
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# file2
nothing added to commit but untracked files present (use “git add” to track)

[mshaik@ansible repo]$ git add .

[mshaik@ansible repo]$ git status
# On branch master
# Changes to be committed:
# (use “git reset HEAD <file>…” to unstage)
#
# new file: file2
#

[mshaik@ansible repo]$ git commit -m “New text file”
[master 73e953c] New text file
1 file changed, 1 insertion(+)
create mode 100644 file2

[mshaik@ansible repo]$ rm -rf file2
[mshaik@ansible repo]$ git status
# On branch master
# Changes not staged for commit:
# (use “git add/rm <file>…” to update what will be committed)
# (use “git checkout — <file>…” to discard changes in working directory)
#
# deleted: file2
#
no changes added to commit (use “git add” and/or “git commit -a”)
[mshaik@ansible repo]$ git commit -m “Removed file2”
# On branch master
# Changes not staged for commit:
# (use “git add/rm <file>…” to update what will be committed)
# (use “git checkout — <file>…” to discard changes in working directory)
#
# deleted: file2
#
no changes added to commit (use “git add” and/or “git commit -a”)

[mshaik@ansible repo]$ git status
# On branch master
# Changes not staged for commit:
# (use “git add/rm <file>…” to update what will be committed)
# (use “git checkout — <file>…” to discard changes in working directory)
#
# deleted: file2
#
no changes added to commit (use “git add” and/or “git commit -a”)

[mshaik@ansible repo]$ ls -l
total 12
-rw-rw-r– 1 mshaik mshaik 10 Jun 2 01:34 file1
-rw-rw-r– 1 mshaik mshaik 47 Jun 2 01:39 README.MD
-rw-rw-r– 1 mshaik mshaik 27 Jun 2 01:30 source.c

[mshaik@ansible repo]$ git rm file2
rm ‘file2’
[mshaik@ansible repo]$ git status
# On branch master
# Changes to be committed:
# (use “git reset HEAD <file>…” to unstage)
#
# deleted: file2
#

[mshaik@ansible repo]$ git commit -m “Removed file2”
[master 0eb35f8] Removed file2
1 file changed, 1 deletion(-)
delete mode 100644 file2

####################################################################

[mshaik@ansible repo]$ git log
commit 0eb35f82d91fc231b0735a3a85c6b53c379332bc
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 02:00:46 2017 +0530

Removed file2

commit 73e953c0643061c55344bb3839e39c58547b3472
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:48:11 2017 +0530

New text file

commit 967983011f6533cfdb4cc9450292224a3306011b
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:42:59 2017 +0530

saving changes to README.MD

commit d1ce1299710f0bec5f4ecca7dc3f7e5cd52c4edb
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:37:33 2017 +0530

this is my first commit

[mshaik@ansible repo]$ git log –oneline
0eb35f8 Removed file2
73e953c New text file
9679830 saving changes to README.MD
d1ce129 this is my first commit

[mshaik@ansible repo]$ git log -p
commit 0eb35f82d91fc231b0735a3a85c6b53c379332bc
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 02:00:46 2017 +0530

Removed file2

diff –git a/file2 b/file2
deleted file mode 100644
index 5413ef1..0000000
— a/file2
+++ /dev/null
@@ -1 +0,0 @@
-This is second file in repo

commit 73e953c0643061c55344bb3839e39c58547b3472
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:48:11 2017 +0530

New text file

diff –git a/file2 b/file2
new file mode 100644
index 0000000..5413ef1
— /dev/null
+++ b/file2
@@ -0,0 +1 @@
+This is second file in repo

commit 967983011f6533cfdb4cc9450292224a3306011b
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:42:59 2017 +0530

saving changes to README.MD

diff –git a/README.MD b/README.MD
index adacbf9..278bd10 100644
— a/README.MD
+++ b/README.MD
@@ -1 +1,2 @@
This is a Readme file
+this is newly added data

commit d1ce1299710f0bec5f4ecca7dc3f7e5cd52c4edb
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:37:33 2017 +0530

this is my first commit

diff –git a/README.MD b/README.MD
new file mode 100644
index 0000000..adacbf9
— /dev/null
+++ b/README.MD
@@ -0,0 +1 @@
+This is a Readme file
diff –git a/file1 b/file1
new file mode 100644
index 0000000..524acff
— /dev/null
+++ b/file1
@@ -0,0 +1 @@
+Test file
diff –git a/source.c b/source.c
new file mode 100644
index 0000000..1f47dc4
— /dev/null
+++ b/source.c
@@ -0,0 +1 @@
+/* This is a readme file*/

[mshaik@ansible repo]$ git log — file2
commit 0eb35f82d91fc231b0735a3a85c6b53c379332bc
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 02:00:46 2017 +0530

Removed file2

commit 73e953c0643061c55344bb3839e39c58547b3472
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:48:11 2017 +0530

New text file

[mshaik@ansible repo]$ git log — file1
commit d1ce1299710f0bec5f4ecca7dc3f7e5cd52c4edb
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:37:33 2017 +0530

this is my first commit

[mshaik@ansible repo]$ git log — file3

[mshaik@ansible repo]$ git log –oneline — file2
0eb35f8 Removed file2
73e953c New text file

[mshaik@ansible repo]$ git log –oneline — file1
d1ce129 this is my first commit

[mshaik@ansible repo]$ git log –author=”rafi494″
commit 0eb35f82d91fc231b0735a3a85c6b53c379332bc
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 02:00:46 2017 +0530

Removed file2

commit 73e953c0643061c55344bb3839e39c58547b3472
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:48:11 2017 +0530

New text file

commit 967983011f6533cfdb4cc9450292224a3306011b
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:42:59 2017 +0530

saving changes to README.MD

commit d1ce1299710f0bec5f4ecca7dc3f7e5cd52c4edb
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:37:33 2017 +0530

this is my first commit

[mshaik@ansible repo]$ git log –grep=”change”
commit 967983011f6533cfdb4cc9450292224a3306011b
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:42:59 2017 +0530

saving changes to README.MD

[mshaik@ansible repo]$ git log –graph
* commit 0eb35f82d91fc231b0735a3a85c6b53c379332bc
| Author: rafi494 <mohammedrafi494@gmail.com>
| Date: Fri Jun 2 02:00:46 2017 +0530
|
| Removed file2
|
* commit 73e953c0643061c55344bb3839e39c58547b3472
| Author: rafi494 <mohammedrafi494@gmail.com>
| Date: Fri Jun 2 01:48:11 2017 +0530
|
| New text file
|
* commit 967983011f6533cfdb4cc9450292224a3306011b
| Author: rafi494 <mohammedrafi494@gmail.com>
| Date: Fri Jun 2 01:42:59 2017 +0530
|
| saving changes to README.MD
|
* commit d1ce1299710f0bec5f4ecca7dc3f7e5cd52c4edb
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 01:37:33 2017 +0530

this is my first commit

[mshaik@ansible repo]$ git log –graph –decorate

[mshaik@ansible repo]$ man git log

############################################################################

[mshaik@ansible repo]$ cd
[mshaik@ansible ~]$ mkdir workingdir
[mshaik@ansible ~]$ cd workingdir/
[mshaik@ansible workingdir]$

[mshaik@ansible workingdir]$ git clone /home/mshaik/repo/ .
Cloning into ‘.’…
done.
[mshaik@ansible workingdir]$ ls -la
total 16
drwxrwxr-x 3 mshaik mshaik 60 Jun 2 02:44 .
drwx——. 5 mshaik mshaik 4096 Jun 2 02:41 ..
-rw-rw-r– 1 mshaik mshaik 10 Jun 2 02:44 file1
drwxrwxr-x 8 mshaik mshaik 152 Jun 2 02:44 .git
-rw-rw-r– 1 mshaik mshaik 47 Jun 2 02:44 README.MD
-rw-rw-r– 1 mshaik mshaik 27 Jun 2 02:44 source.c

[mshaik@ansible workingdir]$ git add .

[mshaik@ansible workingdir]$ git status
# On branch master
# Changes to be committed:
# (use “git reset HEAD <file>…” to unstage)
#
# modified: file1
#

[mshaik@ansible workingdir]$ git commit -m “modifyed local repo”
[master b0b648b] modifyed local repo
1 file changed, 5 insertions(+)
[mshaik@ansible workingdir]$ git status
# On branch master
# Your branch is ahead of ‘origin/master’ by 1 commit.
# (use “git push” to publish your local commits)
#
nothing to commit, working directory clean
[mshaik@ansible workingdir]$ cat file1
Test file
2
3
4
5
6

[mshaik@ansible workingdir]$ cat ../repo/file1
Test file

mohammedrafi@NOC-RAFI:~/remote$ git clone mshaik@192.168.183.128:repo .
Cloning into ‘.’…
mshaik@192.168.183.128’s password:
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 12 (delta 2), reused 0 (delta 0)
Receiving objects: 100% (12/12), done.
Resolving deltas: 100% (2/2), done.
Checking connectivity… done.

mohammedrafi@NOC-RAFI:~/remote$ ls -la
total 24
drwxrwxr-x 3 mohammedrafi mohammedrafi 4096 Jun 2 02:55 .
drwxr-xr-x 48 mohammedrafi mohammedrafi 4096 Jun 2 02:53 ..
-rw-rw-r– 1 mohammedrafi mohammedrafi 10 Jun 2 02:55 file1
drwxrwxr-x 8 mohammedrafi mohammedrafi 4096 Jun 2 02:55 .git
-rw-rw-r– 1 mohammedrafi mohammedrafi 47 Jun 2 02:55 README.MD
-rw-rw-r– 1 mohammedrafi mohammedrafi 27 Jun 2 02:55 source.c
mohammedrafi@NOC-RAFI:~/remote$ cat file1
Test file

#######################################################################################

[mshaik@ansible repo]$ git status
# On branch master
nothing to commit, working directory clean

[mshaik@ansible repo]$ echo “new file” > newfile

[mshaik@ansible repo]$ git status
# On branch master
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# newfile
nothing added to commit but untracked files present (use “git add” to track)

[mshaik@ansible repo]$ git add .

[mshaik@ansible repo]$ git commit -m “newly added file in to dir”
[master 750062c] newly added file in to dir
1 file changed, 1 insertion(+)
create mode 100644 newfile

[mshaik@ansible repo]$ git status
# On branch master
nothing to commit, working directory clean

[mshaik@ansible repo]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mshaik/.ssh/id_rsa):
Created directory ‘/home/mshaik/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/mshaik/.ssh/id_rsa.
Your public key has been saved in /home/mshaik/.ssh/id_rsa.pub.
The key fingerprint is:
25:80:b5:4a:de:b2:c9:21:fa:ba:9c:91:06:95:0d:c4 mshaik@ansible
The key’s randomart image is:
+–[ RSA 2048]—-+
| oo oo |
| E+. o |
| o o . . . |
| . o o o |
|. . = . S |
|…o = |
|.+ + |
|o.o |
|o=. |
+—————–+
[mshaik@ansible repo]$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDs/d8g0HSrf1KyBIbxB/C/3I2czC7npZ5XSKj3rttOZLUzH7dy1LFXFkt1TvXBO5p47yrGn1dI6ZBPDS2UQLwocFUdE1xV+t9s0lGXWThR/V5GfEDD5+fnM50VJggeOb3iA75XnaOCy/MY9rP/5PSLfdCV43Z8y1/8upc5qut+VaakgeBIBLzmpRTpspA6kD9MjPlIV/Aa5VDcL3HKWqH4Laaakyf1GVUZxoAugZAjm+Q3mXGoBDX7jbzB8M5m1pxob9SQGDhBYO5u3a0lEly0ysVNA8KoOXpGMH/UlHoDY6TZvNtpjAVj80K5bsgRGUlIMEvlDOdXlNEHFBSWdaaH mshaik@ansible

https://github.com/settings/ssh

[mshaik@ansible repo]$ ssh -T git@github.com
The authenticity of host ‘github.com (192.30.253.112)’ can’t be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36: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.112’ (RSA) to the list of known hosts.
Hi rafi494! You’ve successfully authenticated, but GitHub does not provide shell access.

https://github.com/new

https://github.com/rafi494/quickstart

[mshaik@ansible repo]$ git clone git@github.com:rafi494/quickstart.git
Cloning into ‘quickstart’…
warning: You appear to have cloned an empty repository.

[mshaik@ansible repo]$ git add .

[mshaik@ansible repo]$ git commit -m “pushing to quick start repo”

[mshaik@ansible repo]$ cd quickstart/
[mshaik@ansible quickstart]$ ls -la
total 0
drwxrwxr-x 3 mshaik mshaik 17 Jun 2 04:03 .
drwxrwxr-x 4 mshaik mshaik 91 Jun 2 04:03 ..
drwxrwxr-x 7 mshaik mshaik 111 Jun 2 04:04 .git
[mshaik@ansible quickstart]$ ls -la .git/
total 16
drwxrwxr-x 7 mshaik mshaik 111 Jun 2 04:04 .
drwxrwxr-x 3 mshaik mshaik 17 Jun 2 04:03 ..
drwxrwxr-x 2 mshaik mshaik 6 Jun 2 04:03 branches
-rw-rw-r– 1 mshaik mshaik 262 Jun 2 04:04 config
-rw-rw-r– 1 mshaik mshaik 73 Jun 2 04:03 description
-rw-rw-r– 1 mshaik mshaik 23 Jun 2 04:03 HEAD
drwxrwxr-x 2 mshaik mshaik 4096 Jun 2 04:03 hooks
drwxrwxr-x 2 mshaik mshaik 20 Jun 2 04:03 info
drwxrwxr-x 4 mshaik mshaik 28 Jun 2 04:03 objects
drwxrwxr-x 4 mshaik mshaik 29 Jun 2 04:03 refs

[mshaik@ansible quickstart]$ git remote
origin

[mshaik@ansible quickstart]$ echo “into quick start repo” >> first_file
[mshaik@ansible quickstart]$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# first-fileinto quick start repo
# first_file
nothing added to commit but untracked files present (use “git add” to track)

[mshaik@ansible quickstart]$ git add .

[mshaik@ansible quickstart]$ git commit -m “Iniitial commit”
[master (root-commit) a75d028] Iniitial commit
2 files changed, 1 insertion(+)
create mode 100644 first-fileinto quick start repo
create mode 100644 first_file

[mshaik@ansible quickstart]$ git remote
origin

[mshaik@ansible quickstart]$ git push origin master
Warning: Permanently added the RSA host key for IP address ‘192.30.255.113’ to the list of known hosts.
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 296 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/quickstart.git
* [new branch] master -> master

[mshaik@ansible quickstart]$ git status
# On branch master
nothing to commit, working directory clean

[mshaik@ansible quickstart]$ git log
commit a75d02817be2c77002760f5d6e920230f95e1c4f
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Fri Jun 2 04:09:43 2017 +0530

Iniitial commit
[mshaik@ansible quickstart]$ git log –oneline
a75d028 Iniitial commit

[mshaik@ansible quickstart]$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote “origin”]
url = git@github.com:rafi494/quickstart.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch “master”]
remote = origin
merge = refs/heads/master

[mshaik@ansible quickstart]$ git config –global core.excludesfile ‘/etc/gitignore’

[mshaik@ansible quickstart]$ git config –global core.excludesfile ‘/etc/gitignore’
[mshaik@ansible quickstart]$ cat /etc/gitignore
cat: /etc/gitignore: No such file or directory
[mshaik@ansible quickstart]$ sudo vim /etc/gitignore
#globally ignore complied .out binary files
*.out

[mshaik@ansible quickstart]$ cat /etc/gitignore
#globally ignore complied .out binary files
*.out
[mshaik@ansible quickstart]$ cp first_file second.out
[mshaik@ansible quickstart]$ ll
total 8
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:09 first_file
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:25 second.out
[mshaik@ansible quickstart]$ git status
# On branch master
nothing to commit, working directory clean

[mshaik@ansible quickstart]$ cp first_file third.txt
[mshaik@ansible quickstart]$ git status
# On branch master
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# third.txt
nothing added to commit but untracked files present (use “git add” to track)

[mshaik@ansible quickstart]$ git add .
[mshaik@ansible quickstart]$ git commit -m “new .txt file”
[master d29c67c] new .txt file
1 file changed, 1 insertion(+)
create mode 100644 third.txt
[mshaik@ansible quickstart]$ git status
# On branch master
# Your branch is ahead of ‘origin/master’ by 1 commit.
# (use “git push” to publish your local commits)
#
nothing to commit, working directory clean

[mshaik@ansible quickstart]$ mkdir dir1
[mshaik@ansible quickstart]$ cat >> dir1/test
hello added sufessfully new file in dir
[mshaik@ansible quickstart]$ git status
# On branch master
# Untracked files:
# (use “git add <file>…” to include in what will be committed)
#
# dir1/
nothing added to commit but untracked files present (use “git add” to track)
[mshaik@ansible quickstart]$ git add .
[mshaik@ansible quickstart]$ git commit -m “new file in dir1 added to repo”
[master 023b5f9] new file in dir1 added to repo
1 file changed, 1 insertion(+)
create mode 100644 dir1/test
[mshaik@ansible quickstart]$ git push origin master
Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 354 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To git@github.com:rafi494/quickstart.git
8a2415c..023b5f9 master -> master

[mshaik@ansible quickstart]$ git branch
* master

[mshaik@ansible quickstart]$ git branch dev
[mshaik@ansible quickstart]$ git branch
dev
* master
[mshaik@ansible quickstart]$ git checkout dev
Switched to branch ‘dev’
[mshaik@ansible quickstart]$ git branch
* dev
master

[mshaik@ansible quickstart]$ git status
# On branch dev
nothing to commit, working directory clean

[mshaik@ansible quickstart]$ ls -l
total 16
drwxrwxr-x 2 mshaik mshaik 17 Jun 2 04:39 dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:09 first_file
-rw-rw-r– 1 mshaik mshaik 11 Jun 2 04:36 new file in dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:25 second.out
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:26 third.txt

[mshaik@ansible quickstart]$ rm -rf new\ file\ in\ dir1

[mshaik@ansible quickstart]$ ls -l
total 12
drwxrwxr-x 2 mshaik mshaik 17 Jun 2 04:39 dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:09 first_file
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:25 second.out
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:26 third.txt

[mshaik@ansible quickstart]$ git rm new\ file\ in\ dir1
rm ‘new file in dir1’

[mshaik@ansible quickstart]$ git commit -m “removed one file”
[dev 7b9e765] removed one file
1 file changed, 1 deletion(-)
delete mode 100644 new file in dir1

[mshaik@ansible quickstart]$ git branch
* dev
master

[mshaik@ansible quickstart]$ git push origin dev
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 221 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To git@github.com:rafi494/quickstart.git
* [new branch] dev -> dev
[mshaik@ansible quickstart]$ git checkout -b production
Switched to a new branch ‘production’
[mshaik@ansible quickstart]$ git status
# On branch production
nothing to commit, working directory clean
[mshaik@ansible quickstart]$ git branch
dev
master
* production

[mshaik@ansible quickstart]$ echo “file one” > one
[mshaik@ansible quickstart]$ echo “file two” > two
[mshaik@ansible quickstart]$ echo “file three” > three

[mshaik@ansible quickstart]$ git add .
[mshaik@ansible quickstart]$ git commit -m “added production branch and couple of new files”
[production 29c11fb] added production branch and couple of new files
3 files changed, 3 insertions(+)
create mode 100644 one
create mode 100644 three
create mode 100644 two
[mshaik@ansible quickstart]$ git branch
dev
master
* production
[mshaik@ansible quickstart]$ git push origin production
Counting objects: 6, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (5/5), 435 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/quickstart.git
* [new branch] production -> production
[mshaik@ansible quickstart]$ git status
# On branch production
nothing to commit, working directory clean

[mshaik@ansible quickstart]$ git branch
dev
master
* production
[mshaik@ansible quickstart]$ ll
total 24
drwxrwxr-x 2 mshaik mshaik 17 Jun 2 04:39 dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:09 first_file
-rw-rw-r– 1 mshaik mshaik 9 Jun 2 05:07 one
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:25 second.out
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:26 third.txt
-rw-rw-r– 1 mshaik mshaik 11 Jun 2 05:08 three
-rw-rw-r– 1 mshaik mshaik 9 Jun 2 05:08 two
[mshaik@ansible quickstart]$ git checkout master
Switched to branch ‘master’
[mshaik@ansible quickstart]$ ll
total 16
drwxrwxr-x 2 mshaik mshaik 17 Jun 2 04:39 dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:09 first_file
-rw-rw-r– 1 mshaik mshaik 11 Jun 2 05:16 new file in dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:25 second.out
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:26 third.txt
[mshaik@ansible quickstart]$ git checkout dev
Switched to branch ‘dev’
[mshaik@ansible quickstart]$ ll
total 12
drwxrwxr-x 2 mshaik mshaik 17 Jun 2 04:39 dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:09 first_file
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:25 second.out
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:26 third.txt

################################################################

[mshaik@ansible quickstart]$ git push origin –all
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/quickstart.git
* [new branch] qa -> qa
* [new branch] tmp -> tmp
[mshaik@ansible quickstart]$ git branch
* dev
master
production
qa
tmp

[mshaik@ansible quickstart]$ git checkout master
Switched to branch ‘master’

[mshaik@ansible quickstart]$ git merge qa
Updating 023b5f9..7b9e765
Fast-forward
new file in dir1 | 1 –
1 file changed, 1 deletion(-)
delete mode 100644 new file in dir1

[mshaik@ansible quickstart]$ git status
# On branch master
# Your branch is ahead of ‘origin/master’ by 1 commit.
# (use “git push” to publish your local commits)
#
nothing to commit, working directory clean

[mshaik@ansible quickstart]$ git push origin master
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/quickstart.git
023b5f9..7b9e765 master -> master
[mshaik@ansible quickstart]$ git branch
dev
* master
production
qa
tmp
[mshaik@ansible quickstart]$ ll
total 12
drwxrwxr-x 2 mshaik mshaik 17 Jun 2 04:39 dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:09 first_file
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:25 second.out
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:26 third.txt

[mshaik@ansible quickstart]$ git merge production
Updating 7b9e765..29c11fb
Fast-forward
one | 1 +
three | 1 +
two | 1 +
3 files changed, 3 insertions(+)
create mode 100644 one
create mode 100644 three
create mode 100644 two
[mshaik@ansible quickstart]$ git push origin master
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/quickstart.git
7b9e765..29c11fb master -> master

[mshaik@ansible quickstart]$ ll
total 24
drwxrwxr-x 2 mshaik mshaik 17 Jun 2 04:39 dir1
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:09 first_file
-rw-rw-r– 1 mshaik mshaik 9 Jun 2 06:12 one
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:25 second.out
-rw-rw-r– 1 mshaik mshaik 22 Jun 2 04:26 third.txt
-rw-rw-r– 1 mshaik mshaik 11 Jun 2 06:12 three
-rw-rw-r– 1 mshaik mshaik 9 Jun 2 06:12 two

###################################################################

git config –global core.editor vim
git config –global core.pager ‘more’
git config –global core.excludesfile ~/.gitignore_global
git config –list
git log –stat
git log -p -2
git log –pretty=oneline
git log –pretty=format:”%h: %an, &ae,%cn ,%ce,%cd, – %s” –graph

git tag tag1
git tag
echo “for tagging concept” > posttag1
git add posttag1
git commit -m “tag1 commited”
git show tag1
git describe –tags
git tag -a v1 -m “version one releasd”
git tag
echo “this is tag2” >> posttag2
git add posttag2
git commit -m “commit after tag2”
git show v1
git describe –tags

git merge development –no-ff

Leave a comment