git 服務器安裝

說明:記錄一下

useradd git
yum install git-core
su git
mkdir /home/git/repositories
git init --bare myprj

在任意一個客戶端執行

如果沒有安裝git,可以先執行 yum install git

設置客戶端的用戶名和email

git config --global user.name name1
git config --global user.email [email protected]

初始化

mkdir initial.commit
cd initial.commit/
git init
git remote add origingit@node2:/home/git/repositories/myprj/
touch Readme
git add .
git commit -m "add Readme"

安裝完成

 

客戶端使用方法:

先配置ssh免密碼登陸

設置用戶名和email

git config --global user.name name1
git config --global user.email [email protected]

然後在客戶端執行

同步版本庫

git clonegit@node2:/home/git/repositories/myprj/

提交本地文件到服務器上

touch test1
git add test1
git commit -m "add test1"
git push

下載服務器上的版本庫到本地

git pull


配置ssh免登陸方法

在客戶端執行

ssh-keygen 然後一直回車

在服務器端執行

mkdir -p /home/git/.ssh/
touch  /home/git/.ssh/authorized_keys

拷貝客戶端的公鑰到服務器端的authorized_keys

客戶端公鑰位置: /home/name1/.ssh/id_rsa.pub name1爲客戶端用戶名,將id_rsa.pub中的內容寫入到authorized_keys

chmod 600 authorized_keys

完成,測試方法 ssh git@node2 直接可以登陸


參考鏈接:http://aoingl.iteye.com/blog/1365201

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章