2009年9月15日 星期二

GIT : Remote Repository

0.環境描述

git config --global user.name "Steve Chang"
git config --global user.email stevegigijoe@yahoo.com.tw

gigijoe@user-desktop:~/myandroid$ git config -l
color.ui=auto
user.name=Steve Chang
user.email=stevegigijoe@yahoo.com.tw

sdaemon2專案原始碼在Client端.
建立Client端GIT專案sdaemon2
設定GIT遠端伺服器並建立GIT專案 sdaemon2.
將sdaemon2提交伺服器端

1.伺服器端設定

adduser git
su git
mkdir sdaemon2.git
cd sdaemon2.git
git --bare init

之後會看到以下訊息
Initialized empty Git repository in /home/git/sdaemon2.git

2.Client端GIT專案

cd sdaemon2
git add .
git commit

git log

commit 86c36413882cc8e364c7764e47c025b4c8930437
Author: Steve Chang
Date:   Tue Sep 15 16:03:15 2009 +0800

    Initial version of sdaemon2

git remote add origin git@[server]:sdaemon2.git
git push origin master

The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is 22:f6:c8:69:bb:36:d2:fb:99:5a:f9:62:32:68:75:c3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
git@localhost's password:
Counting objects: 34, done.
Compressing objects: 100% (34/34), done.
Writing objects: 100% (34/34), 43.87 KiB, done.
Total 34 (delta 0), reused 0 (delta 0)
To git@localhost:sdaemon2.git
 * [new branch]      master -> master

git config -l

color.ui=auto
user.name=Steve Chang
user.email=stevegigijoe@yahoo.com.tw
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@localhost:sdaemon2.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

3.其他的Client取得GIT專案

git clone git@[server]:sdaemon2.git

Initialized empty Git repository in /home/gigijoe/VT300/sdaemon2/.git/
git@localhost's password:
remote: Counting objects: 34, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 34 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (34/34), 43.87 KiB, done.

這時會在目前位置複製一份sdaemon2目錄及原始碼

4.提交更動(commit)

git commit -a

Created commit 9c91092: Add debug message on state machine
 1 files changed, 10 insertions(+), 10 deletions(-)

git push origin master

git@localhost's password:
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 421 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To git@localhost:sdaemon2.git
   86c3641..9c91092  master -> master

5.提取更新

git pull

git@localhost's password:
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From git@localhost:sdaemon2
   86c3641..9c91092  master     -> origin/master
Updating 86c3641..9c91092
Fast forward
 networking.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

6.差異比較

與前一版的差異
git diff HEAD^

or

git show HEAD

與前兩版的差異
git diff HEAD^^

or

git show HEAD^


與前前前前一版的差異
git diff HEAD~4

or

git show HEAD~3


Referance

http://www.wretch.cc/blog/michaeloil/22286355

http://plog.longwin.com.tw/my_note-unix/2009/05/19/git-learn-initial-command-2009

http://www.qweruiop.org/nchcrails/posts/49



沒有留言:

張貼留言