Server 端:
1.在server上安裝git server
2.增加一個(gè)用戶(hù)組
[root@ATE lgs]# groupadd lgs ? ?# 添加組lgs
[root@ATE lgs]# vi /etc/group ? ?# 系統(tǒng)的組文件
[root@ATE lgs]# groups xingyanl ?#查看某個(gè)用戶(hù)屬于哪個(gè)組
3.添加用戶(hù)
[root@ATE lgs]# useradd -M xingyanl ? # -M在home 目錄下面不創(chuàng)建用戶(hù)目錄
4.添加用戶(hù)到組
[root@ATE home]# usermod -G lgs xingyanl ? # 只屬于lgs組
[root@ATE home]# usermod -a -G lgs leitao ? ?# 還可能屬于其他組
[root@ATE home]# vi /etc/passwd ? #修改登錄類(lèi)型為git,還有home目錄
/usr/bin/git-shell
?xingyanl:x:525:525::/home/lgs:/usr/local/bin/git-shell
5.初始化一個(gè)git倉(cāng)庫(kù)
[root@ATE lgs]# git init --bare lgs.git
[root@ATE lgs]# chown -R longbl:lgs lgs.git ? ? # 改變目錄的所有者owner
[root@ATE lgs]# chmod -R 775 lgs.git ? # 改變目錄的讀寫(xiě)權(quán)限
client 端:
$ git clone xingyanl@135.251.123.178:lgs.git ?? #user:xingyanl password:asb#1234
Cloning into 'lgs'...
xingyanl@135.251.123.178's password:
warning: You appear to have cloned an empty repository.
$ vi test_git.text
$ git add test_git.text ? # 添加文件
warning: LF will be replaced by CRLF in test_git.text.
The file will have its original line endings in your working directory.
$ git commit -m "test git file" ?# 提交文件,-m參數(shù)是提交文件的說(shuō)明
[master (root-commit) 801cb70] test git file
1 file changed, 1 insertion(+)
create mode 100644 test_git.text
$ git push -u ?origin master ?# 上傳到服務(wù)器
xingyanl@135.251.123.178's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 239 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To 135.251.123.178:lgs.git
* [new branch]? ? ? master -> master
Branch master set up to track remote branch master from origin.
$ git pull ? ?# 從服務(wù)器把數(shù)據(jù)拿出來(lái)
xingyanl@135.251.123.178's password:
Already up-to-date.
xingyanl@CA0068634N0 MINGW64 /d/lgs (master)
1 xingyanl:x:525:525::/home/lgs:/usr/local/bin/git-shell1 xingyanl:x:525:525::/home/lgs:/usr/local/bin/git-shell