debian下安装git服务器
2018-01-04 18:17
197 查看
① 安装 Git
Linux 做为服务器端系统,Windows 作为客户端系统,分别安装 Git服务器端:
#yum install -y git
安装完后,查看 Git 版本
[root@localhost ~]# git --version git version 1.7.1
客户端:
下载 Git for Windows,地址:https://git-for-windows.github.io/
安装完之后,可以使用 Git Bash 作为命令行客户端。
安装完之后,查看 Git 版本
$ git --version git version 2.8.4.windows.1
② 服务器端创建 git 用户,用来管理 Git 服务,并为 git 用户设置密码
[root@localhost home]# id git id: git:无此用户 [root@localhost home]# useradd git [root@localhost home]# passwd git
③ 服务器端创建 Git 仓库
设置 /home/data/git/gittest.git 为 Git 仓库然后把 Git 仓库的 owner 修改为 git
[root@localhost home]# mkdir -p data/git/gittest.git [root@localhost home]# git init --bare data/git/gittest.git Initialized empty Git repository in /home/data/git/gittest.git/ [root@localhost home]# cd data/git/ [root@localhost git]# chown -R git:git gittest.git/
④ 客户端 clone 远程仓库
进入 Git Bash 命令行客户端,创建项目地址(设置在 d:/wamp64/www/gittest_gitbash)并进入:dee@Lenovo-PC MINGW64 /d $ cd wamp64/www dee@Lenovo-PC MINGW64 /d/wamp64/www $ mkdir gittest_gitbash dee@Lenovo-PC MINGW64 /d/wamp64/www $ cd gittest_gitbash dee@Lenovo-PC MINGW64 /d/wamp64/www/gittest_gitbash $
然后从 Linux Git 服务器上 clone 项目:
$ git clone git@192.168.56.101:/home/data/gittest.git
如果SSH用的不是默认的22端口,则需要使用以下的命令(假设SSH端口号是7700):
$ git clone ssh://git@192.168.56.101:7700/home/data/gittest.git
当第一次连接到目标 Git 服务器时会得到一个提示:
The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established. RSA key fingerprint is SHA256:Ve6WV/SCA059EqoUOzbFoZdfmMh3B259nigfmvdadqQ. Are you sure you want to continue connecting (yes/no)?
选择 yes:
查看客户端项目目录:
项目已经 clone 了。
代码同步(HOOK)
上边git用于做了中心的版本控制
但是还想让服务器接到修改更新后自动同步代码到网站目录中,便于测试开发
如下操作是可以实现
#假定网站目录在/www/web下 cd /home/git/repo.git/hooks vim post-receive #创建一个钩子 #写入下面内容 GIT_WORK_TREE=/www/web git checkout -f #保存退出 chown git:git post-receive chmod +x post-receive
如此,下次提交修改,代码会自动同步到指定目录中
相关文章推荐
- Ubuntu Git服务器搭建及Gitosis安装设置
- CentOS 6.4x64安装git和gitolite服务器
- 在linux 下安装git 服务器实现代码自动更新
- centos 安装git服务器,配置使用证书登录并你用hook实现代码自动部署
- Window下搭建Git服务器 - Git安装配置
- Ubuntu 11.10 server 安装Git 服务器
- [转载]Ubuntu下Git服务器安装与配置
- 搭建B/S架构Git服务器及gitlab-ci安装
- 搭建B/S架构Git服务器及gitlab-ci安装
- linux(debian) 下安装ample搭建局域网共享音乐服务器。
- Git服务器Gitosis安装设置
- 安装Git 服务器
- 安装Git 服务器
- CentOS 7下快速安装Gitlab,搭建个人或者公司内部使用的Git服务器
- CentOS 7 安装gogs git代码服务器
- Ubutun 16.04安装git服务器
- Git服务器Gitosis安装设置
- Debian下SVN服务器安装
- Ubuntu下GIT服务器的安装与配置
- Ubuntu 下 Git 服务器的安装和初级配置