一、安裝git
# yum install -y git
二属桦、多用戶及組管理
# groupadd ggit //添加組 ggit
# useradd -M test1
# useradd -M test2 //添加用戶test1 test2
# usermod -G ggit test1 //加入組ggit
# passwd test1 //設(shè)置密碼
查看 /etc/group
三他爸、倉(cāng)庫(kù)管理
# mkdir gitrepo //服務(wù)器端 /home 下建立 gitrepo 倉(cāng)庫(kù)
// 建立第一個(gè)倉(cāng)庫(kù)并初始化
# git init --bare myfirstrepo.git
// 權(quán)限更改
# cd myfirstrepo.git
# chmod -R g+ws *
四聂宾、客戶端創(chuàng)建SSH公鑰和私鑰
# ssh-keygen -t rsa -C “xx@xx.com"
服務(wù)端打開RSA認(rèn)證 /etc/ssh/sshd_config
# service sshd restart //重啟sshd服務(wù)
//gitrepo倉(cāng)庫(kù)下創(chuàng)建.ssh文件夾 所有者為ggit
# chgrp -R gitrepo /home/gitrepo
//將客戶端生成的公鑰id_rsa.pub copy至該文件
# vi /home/gitrepo/.ssh/authorized_keys
//修改權(quán)限
# chmod 700 .ssh
# chmod 600 authorized_keys
//安全考慮禁止創(chuàng)建的用戶通過(guò)ssh登錄服務(wù)器
# /etc/passwd
/home/gitrepo:/bin/bash 改為 /home/gitrepo:/bin/git-shell
五系谐、客戶端訪問(wèn)git倉(cāng)庫(kù)
# git clone test1@ip:/home/gitrepo/myfirstrepo.git
# git push -u origin master //推送到遠(yuǎn)程倉(cāng)庫(kù)
# git branch 分支名 //創(chuàng)建分支
# git checkout 分支名 //切換分支
# git checkout -b master origin/master
# git merge 分支名 (master 主分支下使用,將分支合并到主分支)
# git remote -v //查看本地倉(cāng)庫(kù)管理的遠(yuǎn)程倉(cāng)庫(kù)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者