working with git

root@NOC-RAFI:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
17:f8:ce:49:fa:61:23:37:61:e6:0e:97:f2:b0:5b:aa root@NOC-RAFI
The key’s randomart image is:
+–[ RSA 2048]—-+
| |
| . |
| . . |
| . . |
| S B |
| X + |
| * # |
| / + |
| E.+.+ |
+—————–+

=========================================
root@NOC-RAFI:~# apt-get install git -y

or yum install git -y
=========================================
root@NOC-RAFI:~# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDP0NOxF6BLWKnqebywRa8YUsLPELM29y9o6XuxUgoJX+Nehy0wPaFpa2bkcUHcXBD+px8N2UH4mZ/jez2rsLRy6A0Kl8SazdqT+SBNA0Rtv8Gzg9H+5rpnLddel6SA3fc3b6x692dH1dAucobwQg5WAW7sqUSAFj5ugHDNZ25ryTrsv/tMOjuWXbqDv15VUpwqDT90MJkOsNHsgCDIx0XepwanlHCTYJNV0KxMd0q98DY5664ftZ3MgiC6hb9gs93Q9KMG9ZD+SIEUdHMGdmAzRK68+m2my+zPwYSIvTkZ5n2eJG85c+gVOUv2HaKJtX69PkySK5cMvc6ujnKwHP9T root@NOC-RAFI
=========================================
https://github.com/settings/ssh

2.png
=========================================
root@NOC-RAFI:~# 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: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.113’ (RSA) to the list of known hosts.
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Hi rafi494! You’ve successfully authenticated, but GitHub does not provide shell access.

https://github.com/settings/repositories

https://github.com/rafi494/first

3.png
=========================================
root@NOC-RAFI:~# git clone git@github.com:rafi494/first.git
Cloning into ‘first’…
Enter passphrase for key ‘/root/.ssh/id_rsa’:
warning: You appear to have cloned an empty repository.
Checking connectivity… done.

root@NOC-RAFI:~# ls -l
total 8
drwxr-xr-x 3 root root 4096 Dec 20 17:42 first
=========================================
root@NOC-RAFI:~# cd first/
=========================================
root@NOC-RAFI:~/first# ll
total 12
drwxr-xr-x 3 root root 4096 Dec 20 17:42 ./
drwx—— 10 root root 4096 Dec 20 18:21 ../
drwxr-xr-x 7 root root 4096 Dec 20 17:42 .git/
=========================================
root@NOC-RAFI:~/first# git remote
origin
=========================================
root@NOC-RAFI:~/first# cd .git/
=========================================
root@NOC-RAFI:~/first/.git# ll
total 40
drwxr-xr-x 7 root root 4096 Dec 20 17:42 ./
drwxr-xr-x 3 root root 4096 Dec 20 17:42 ../
drwxr-xr-x 2 root root 4096 Dec 20 17:42 branches/
-rw-r–r– 1 root root 257 Dec 20 17:42 config
-rw-r–r– 1 root root 73 Dec 20 17:42 description
-rw-r–r– 1 root root 23 Dec 20 17:42 HEAD
drwxr-xr-x 2 root root 4096 Dec 20 17:42 hooks/
drwxr-xr-x 2 root root 4096 Dec 20 17:42 info/
drwxr-xr-x 4 root root 4096 Dec 20 17:42 objects/
drwxr-xr-x 4 root root 4096 Dec 20 17:42 refs/
=========================================
root@NOC-RAFI:~/first# git remote -v
origin git@github.com:rafi494/first.git (fetch)
origin git@github.com:rafi494/first.git (push)
=========================================
root@NOC-RAFI:~/first# vim testing
hai this will my first test data
=========================================
root@NOC-RAFI:~/first# git status
On branch master

Initial commit

Untracked files:
(use “git add …” to include in what will be committed)

testing

nothing added to commit but untracked files present (use “git add” to track)

root@NOC-RAFI:~/first# git add testing
=========================================
root@NOC-RAFI:~/first# git status
On branch master

Initial commit

Changes to be committed:
(use “git rm –cached …” to unstage)

new file: testing
=========================================
root@NOC-RAFI:~/first# git commit -a

*** 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: unable to auto-detect email address (got ‘root@NOC-RAFI.(none)’)
=========================================
root@NOC-RAFI:~/first# git config -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:rafi494/first.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
=========================================
root@NOC-RAFI:~/first# git config –global user.name “rafi494”

root@NOC-RAFI:~/first# git config -l
user.name=rafi494
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:rafi494/first.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
=========================================
root@NOC-RAFI:~/first# git config –global user.email “mohammedrafi494@gmail.com”
root@NOC-RAFI:~/first# git config -l
user.name=rafi494
user.email=mohammedrafi494@gmail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:rafi494/first.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
=========================================
root@NOC-RAFI:~/first# git commit -m “new story”
[master (root-commit) 09d216c] new story
1 file changed, 2 insertions(+)
create mode 100644 testing
=========================================
root@NOC-RAFI:~/first# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from ‘matching’ to ‘simple’. To squelch this message
and maintain the current behavior after the default changes, use:

git config –global push.default matching

To squelch this message and adopt the new behavior now, use:

git config –global push.default simple

When push.default is set to ‘matching’, git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative ‘simple’
behavior, which only pushes the current branch to the corresponding
remote branch that ‘git pull’ uses to update the current branch.

See ‘git help config’ and search for ‘push.default’ for further information.
(the ‘simple’ mode was introduced in Git 1.7.11. Use the similar mode
‘current’ instead of ‘simple’ if you sometimes use older versions of Git)

Enter passphrase for key ‘/root/.ssh/id_rsa’:
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as ‘master’.
error: failed to push some refs to ‘git@github.com:rafi494/first.git’

=========================================
root@NOC-RAFI:~/first# git push -u origin master
Warning: Permanently added the RSA host key for IP address ‘192.30.253.112’ to the list of known hosts.
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 3, done.
Writing objects: 100% (3/3), 241 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/first.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
=========================================
root@NOC-RAFI:~/first# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from ‘matching’ to ‘simple’. To squelch this message
and maintain the current behavior after the default changes, use:

git config –global push.default matching

To squelch this message and adopt the new behavior now, use:

git config –global push.default simple

When push.default is set to ‘matching’, git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative ‘simple’
behavior, which only pushes the current branch to the corresponding
remote branch that ‘git pull’ uses to update the current branch.

See ‘git help config’ and search for ‘push.default’ for further information.
(the ‘simple’ mode was introduced in Git 1.7.11. Use the similar mode
‘current’ instead of ‘simple’ if you sometimes use older versions of Git)

Enter passphrase for key ‘/root/.ssh/id_rsa’:
Everything up-to-date
=========================================
root@NOC-RAFI:~/first# git config –global push.default matching

root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Everything up-to-date

root@NOC-RAFI:~/first# git config –global push.default simple

root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Everything up-to-date
=========================================
root@NOC-RAFI:~/first# cat >> second_test
this will final testing

root@NOC-RAFI:~/first# git add second_test

root@NOC-RAFI:~/first# git status
On branch master
Your branch is up-to-date with ‘origin/master’.

Changes to be committed:
(use “git reset HEAD …” to unstage)

new file: second_test

root@NOC-RAFI:~/first# git commit -m “new story”
[master 193a211] new story
1 file changed, 1 insertion(+)
create mode 100644 second_test

root@NOC-RAFI:~/first# 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

root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 295 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/first.git
09d216c..193a211 master -> master
=========================================
root@NOC-RAFI:~/first# cat >> third_file
this will 3rd file for pushing to git

root@NOC-RAFI:~/first# git status
On branch master
Your branch is up-to-date with ‘origin/master’.

Untracked files:
(use “git add …” to include in what will be committed)

third_file

nothing added to commit but untracked files present (use “git add” to track)

root@NOC-RAFI:~/first# git add third_file

root@NOC-RAFI:~/first# git status
On branch master
Your branch is up-to-date with ‘origin/master’.

Changes to be committed:
(use “git reset HEAD …” to unstage)

new file: third_file
root@NOC-RAFI:~/first# git commit -m “new story”
[master 66bf66a] new story
1 file changed, 1 insertion(+)
create mode 100644 third_file

root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 343 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/first.git
193a211..66bf66a master -> master

git.png

1)create a repo “any file name”

2)add repo “git add file name”

3) commit (git commit -m “new story”)

4)push data “git push”

============================================

root@NOC-RAFI:~/first# cat >>fourth
adding this repo with new tag

root@NOC-RAFI:~/first# git add fourth

root@NOC-RAFI:~/first# git commit -m “second tag”
[master cae60d0] second tag
1 file changed, 1 insertion(+)
create mode 100644 fourth

root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 364 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/first.git
66bf66a..cae60d0 master -> master

4.png

Adding second repository

5.png

root@NOC-RAFI:~/first# mkdir secondrepo

root@NOC-RAFI:~/first# cd secondrepo/
root@NOC-RAFI:~/first/secondrepo# git init
Initialized empty Git repository in /root/first/secondrepo/.git/

root@NOC-RAFI:~/first/secondrepo# ll
total 12
drwxr-xr-x 3 root root 4096 Dec 20 19:41 ./
drwxr-xr-x 4 root root 4096 Dec 20 19:41 ../
drwxr-xr-x 7 root root 4096 Dec 20 19:45 .git/
root@NOC-RAFI:~/first/secondrepo# git remote add origin git@github.com:rafi494/repo2.git

root@NOC-RAFI:~/first/secondrepo# git push -u origin master
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 3, done.
Writing objects: 100% (3/3), 233 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:rafi494/repo2.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.

root@NOC-RAFI:~/first/secondrepo# cat >>sample
pushing it to second repo
root@NOC-RAFI:~/first/secondrepo# git add sample
root@NOC-RAFI:~/first/secondrepo# git commit -m “playing”
[master (root-commit) 579f9af] playing
1 file changed, 1 insertion(+)
create mode 100644 sample

root@NOC-RAFI:~/first/secondrepo# git push

6.png

==========================================

root@NOC-RAFI:~/first# cat >>crosscheck
checking weather any error going on

root@NOC-RAFI:~/first# git add crosscheck

root@NOC-RAFI:~/first# git commit -m “from first repo”
[master 4bb6c59] from first repo
1 file changed, 1 insertion(+)
create mode 100644 crosscheck

root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 302 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To git@github.com:rafi494/first.git
cae60d0..4bb6c59 master -> master

7.png

======================================================

root@NOC-RAFI:~/first# git log
commit 4bb6c59b222692ccd31b7b400fd998c14d95b055
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Tue Dec 20 20:08:02 2016 +0530

from first repo

commit cae60d0e3e0476b874ceed5b8fd0001a65f3a2da
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Tue Dec 20 19:13:12 2016 +0530

second tag

commit 66bf66a4675f688b3a975c5d061ec75550caf4e3
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Tue Dec 20 18:55:36 2016 +0530

new story

commit 193a2111a84ae2cda446af7763925f5e275f36a8
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Tue Dec 20 18:48:10 2016 +0530

new story

commit 09d216c770a22fb133c65ce87e58373504177aff
Author: rafi494 <mohammedrafi494@gmail.com>
Date: Tue Dec 20 18:35:42 2016 +0530

new story
=========================
root@NOC-RAFI:~/first# ls
crosscheck fourth secondrepo second_test testing third_file

root@NOC-RAFI:~/first# git rm fourth
rm ‘fourth’

root@NOC-RAFI:~/first# ls
crosscheck secondrepo second_test testing third_file

root@NOC-RAFI:~/first# git commit -m “removed file”
[master f1ec868] removed file
1 file changed, 1 deletion(-)
delete mode 100644 fourth

root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 220 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To git@github.com:rafi494/first.git
4bb6c59..f1ec868 master -> master

====================================================

root@NOC-RAFI:~/first# git mv testing newfile
root@NOC-RAFI:~/first# ls
crosscheck newfile secondrepo second_test third_file
root@NOC-RAFI:~/first# git commit -m “renamed one file”
[master 947fc6a] renamed one file
1 file changed, 0 insertions(+), 0 deletions(-)
rename testing => newfile (100%)
root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 236 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To git@github.com:rafi494/first.git
f1ec868..947fc6a master -> master
root@NOC-RAFI:~/first# ls
crosscheck newfile secondrepo second_test third_file

===================================

root@NOC-RAFI:~/first# git rm –cached newfile
rm ‘newfile’
root@NOC-RAFI:~/first# ls
crosscheck newfile secondrepo second_test third_file
root@NOC-RAFI:~/first# git commit -m “removed with back up”
[master 026266f] removed with back up
1 file changed, 2 deletions(-)
delete mode 100644 newfile
root@NOC-RAFI:~/first# git push
Enter passphrase for key ‘/root/.ssh/id_rsa’:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 226 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To git@github.com:rafi494/first.git
947fc6a..026266f master -> master

==================================================

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s