JavaScript must be enabled in order for you to see "WP Copy Data Protect" effect. However, it seems JavaScript is either disabled or not supported by your browser. To see full result of "WP Copy Data Protector", enable JavaScript by changing your browser options, then try again.

The usage of git and github under the CentOS 6.6 x64


話說,好像有好一陣子沒有Po廢文了,記得上次有在Survey Git使用Server的架設以及搭配Github做應用,但一直找不到時間過程紀錄下來,所以趁著這次機會,好好介紹它一番,至於History的部分可以參考維基,因此廢話不多說,直接看下去吧,如下:

I.Setup private git server

1) Check the related package that’s installed(On S/C site)
#rpm -qa | grep -i git-
perl-Git-1.7.1-3.el6_4.1.noarch
git-1.7.1-3.el6_4.1.x86_64

2) Generate the ssh keypair for usage of git(On client site)
#ssh-keygen -t rsa
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:
1f:b9:78:19:ca:d2:d0:3b:cc:d3:62:03:9e:04:f6:af root@client.labs.org
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| o |
| . o . . |
| = S + |
| o X * = |
| + / * |
| + * |
| E |
+-----------------+

3) Create the related directory and file of ssh for git(On server site)
#adduser git
#passwd git
#su git
#cd ~ && mkdir -p .ssh
#chmod 700 .ssh
#touch .ssh/authorized_keys && chmod 640 .ssh/authorized_keys
#ls -al .ssh/
total 8
drwx------ 2 git git 4096 Jun 19 10:50 .
drwx------ 5 git git 4096 Jun 19 10:29 ..
-rw-r----- 1 git git 0 Jun 19 10:50 authorized_keys

4) Redirect the public key into the authorized_keys(On client site)
#cd .ssh
#cat id_rsa.pub | ssh git@192.168.1.99 "cat >> ~/.ssh/authorized_keys"
#ssh git@192.168.1.99 -> Can verify the part of ssh passwordless

5) Create the related directory and modify the service of ssh(On server site)
#mkdir -p /git/project/test.git
#chown git. -R /git
#vi /etc/ssh/sshd_config
UseDNS no
PermitRootLogin yes
GSSAPIAuthentication no
GSSAPICleanupCredentials no
#service sshd restart

6) Initialize the configuration about the git(On server site)
#su - git
#cd /git/project/test.git
#git init --bare --shared && exit
Initialized empty shared Git repository in /git/project/test.git/
logout

7) Modify the behavior about the login w/ git and create a new project(On server site)
#vi /etc/passwd
git...:/usr/bin/git-shell
### Create new project through the root
#mkdir -p /git/project/willy.sit
#cd /git/project/willy.sit
#git init --bare --shared
Initialized empty shared Git repository in /git/project/willy.sit/
#chown git. -R /git/project/willy.sit

8) Verification the function about the git server(On client site)
#mkdir -p test && cd test
#git init
Initialized empty Git repository in /root/test/.git/
#git config --global user.name willy
#git config --global user.email willy@iori.tw
#git config --global color.ui auto
#git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
#cat >> gittest
hello, this is a test for git server -> Ctrl-D
#git add .
#git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached ..." to unstage)
#
# new file: gittest
#
#git commit -m "First Commit"
[master (root-commit) 27fca74] First Commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 gittest
#git status
# On branch master
nothing to commit (working directory clean)
#git checkout
#git log
commit 27fca7419df571f8bb32541fb01af926ef4e8b65
Author: willy
Date: Fri Jun 19 19:15:13 2015 +0800
First Commit
#git remote add origin git@192.168.1.99:/git/project/test.git
#git remote -v
origin git@192.168.1.99:/git/project/test.git (fetch)
origin git@192.168.1.99:/git/project/test.git (push)
#git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 239 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.1.99:/git/project/test.git
* [new branch] master -> master
git log
commit 27fca7419df571f8bb32541fb01af926ef4e8b65
Author: willy
Date: Fri Jun 19 19:15:13 2015 +0800
First Commit
#cd .. && rm -rf test
#git clone git@192.168.1.99:/git/project/test.git
Initialized empty Git repository in /root/test/.git/
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
#cd test && git log
commit 27fca7419df571f8bb32541fb01af926ef4e8b65
Author: willy
Date: Fri Jun 19 19:15:13 2015 +0800
First Commit
#ls
gittest
#cat gittest
hello, this is a test for git server

ii.Using the github w/ git

1) Setup the configuration about the client site
#mkdir -p willy && cd willy
#git init
Initialized empty Git repository in /root/willy/.git/
#git config --global user.name "iori200098"
#git config --global user.email "iori200098@iori.tw"
#git config --global color.ui auto
#git --version
git version 1.7.1
#cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAA...p9oihabM8GxxrQ== root@client.labs.org


2) Clone the new project and modify the content to the client site
#git clone https://github.com/iori200098/Willy.git
Initialized empty Git repository in /root/willy/Willy/.git/
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
#cd Willy/ && ls
README.md
#cat README.md
# Willy
#cat > README.md
This is test for willy w/ iori.tw
git config --global alias.co checkout
#git co
M README.md
#git status
# On branch master
# Changed but not updated:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: README.md
#
no changes added to commit (use "git add" and/or "git commit -a")

3) Apply the change w/ the project and check the its status
#git add .
#git commit -m 'Modify the content w/ README.md'
[master 8b466b2] Modify the content w/ README.md
1 files changed, 1 insertions(+), 1 deletions(-)
#git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
#git log
commit 8b466b24d2a45a9efd56f881684fa25120dfdcc0
Author: iori200098
Date: Fri Jun 19 21:11:04 2015 +0800
Modify the content w/ README.md
commit 7807da44c0acc242a116bcf5258d468351de2990
Author: ಗಿಯಾನ್ ಡೋರಾ
Date: Fri Jun 19 20:51:06 2015 +0800
Initial commit

4) Setup the configuration about the github and upload it
#git remote rm origin -> Remove the original item
#git remote add origin git@github.com:iori200098/Willy.git
#git remote -v
origin git@github.com:iori200098/Willy.git (fetch)
origin git@github.com:iori200098/Willy.git (push)
#git push origin master
The authenticity of host 'github.com (192.30.252.129)' 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.252.129' (RSA) to the list of known hosts.
Counting objects: 5, done.
Writing objects: 100% (3/3), 287 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:iori200098/Willy.git
7807da4..8b466b2 master -> master

5) Check the status after uploading
#git status
# On branch master
nothing to commit (working directory clean)
#git show
commit 8b466b24d2a45a9efd56f881684fa25120dfdcc0
Author: iori200098
Date: Fri Jun 19 21:11:04 2015 +0800
Modify the content w/ README.md
diff --git a/README.md b/README.md
index 81286ee..935c344 100644
--- a/README.md
+++ b/README.md
@@ -1 +1 @@
-# Willy
+This is test for willy w/ iori.tw
#git grep willy
README.md:This is test for willy w/ iori.tw
#git branch
* master


◎、以上就是the usage of git and github under the CentOS 6.6 x64簡易介紹,至於上述的內容均參考Git官網Tsung大大以及Aven-network文章,如果看倌們對於Git的操作想要更進一步的了解的話,可以欣賞欣賞連猴子都能懂的Git入門指南Git教學研究站的教學,先到這囉,收工哩!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
This site is protected by WP-CopyRightPro