Server 端:
1.在server上安装git server
2.增加一个用户组
[root@ATE lgs]# groupadd lgs # 添加组lgs
[root@ATE lgs]# vi /etc/group # 系统的组文件
[root@ATE lgs]# groups xingyanl #查看某个用户属于哪个组
3.添加用户
[root@ATE lgs]# useradd -M xingyanl # -M在home 目录下面不创建用户目录
4.添加用户到组
[root@ATE home]# usermod -G lgs xingyanl # 只属于lgs组
[root@ATE home]# usermod -a -G lgs leitao # 还可能属于其他组
[root@ATE home]# vi /etc/passwd #修改登录类型为git,还有home目录
/usr/bin/git-shell
xingyanl:x:525:525::/home/lgs:/usr/local/bin/git-shell
5.初始化一个git仓库
[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 # 改变目录的读写权限
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参数是提交文件的说明
[master (root-commit) 801cb70] test git file
1 file changed, 1 insertion(+)
create mode 100644 test_git.text
$ git push -u origin master # 上传到服务器
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 # 从服务器把数据拿出来
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