搭建个人Git服务器及使用

服务器

centos安装可以参照https://blog.csdn.net/u010476739/article/details/102820620

注意:
1.初始化仓库使用git init --bare生成一个裸库,只用来作为共享库,一般不在服务器上做修改。
2.如果使用root账户操作的,一定要是用chown -R git:git * 来给文件夹改变权限,不然客户端push不上去
3.服务器设置ssh不能登录git

客户端

克隆仓库到本地

git clone ssh://[email protected]/repo/test.git

创建dev分支

git branch dev  # 创建本地dev分支
git branch  # 查看分支
git push origin dev:dev # 推送dev到远程,这样远程仓库也有一个dev分支了

注意:
1.客户端如果创建仓库一定使用git init初始化
2.如果想使用dev分支,可以先本地创建dev分支,然后把dev分支 push到服务器上

references

https://segmentfault.com/q/1010000004683286
https://blog.csdn.net/u010476739/article/details/102820620
https://segmentfault.com/a/1190000008091986

猜你喜欢

转载自www.cnblogs.com/RuizGo/p/12200682.html