close

本文章同步於 http://marsz-chen.blogspot.com/2010/12/github.html

先到  https://github.com/  免費註冊

建立新的 repository

 

第一次建立沒有 public key 時, 必須自己先產生一個

http://help.github.com/mac-key-setup/ 有相關教學


[設定 public key]

先備份舊的 public key :

 

cd ~/.ssh
mkdir key_backup
cp id_rsa* key_backup
rm id_rsa*

 

設定新的 public key

 

ssh-keygen -t rsa -C "marsz@test.com"

 

其中 marsz@test.com 是你在 github 登入的email

所有選項直接案空白即可

顯示產生的key

 

cat ~/.ssh/id_rsa.pub

 

 

[繼續建立 Repository]

將複製的 public key 貼到 github 中 (紅色框框部分)

[Client 使用]

安裝: http://git-scm.com/download

git config --global user.name "marsz" #可隨意打

git config --global user.email marsz@xxx.com

marsz@xxx.com 是 github 中使用的帳號

[commit 自己的 code 上去]

複製 git 存取用的 ssh uri

cd xxxx # 你自己的 code dir

git init

git remote add origin git@github.com:MarsChen/php-lib.git

git add .

git commit -m 'my first commit' # my first commit 是註解

git push origin master

之後的 commit

git add . #如果 commit 單一檔案, 可取代 .

git commit -a -m '註解' #commit 給自己

git push origin master # push 至 server

[從 server 上 clone 下來]

第一次checkout 

git clone git@github.com:MarsChen/php-lib.git

日後更新 (如同 svn update)

git pull origin master

[設定 ignore]

# cd 到 local repository 的根目錄下

vim .git/info/exclude

 內容如

.svn                         #所有有.svn的目錄或檔名
system/*                 #任何位置的system目錄下的所有檔案
config/config.php      #任何位置的config目錄下的config.php

arrow
arrow
    全站熱搜

    marsz 發表在 痞客邦 留言(1) 人氣()