ubuntu16.04上搭建git服务器
2017-03-19 16:07
447 查看
1 git服务器搭建
1.1 安装git
zzx@zzx:~$ sudo apt-get install git1.2 创建 git账户
zzx@zzx:~$ sudo adduser git正在添加用户"git"...
正在添加新组"git" (1002)...
正在添加新用户"git" (1001)到组"git"...
创建主目录"/home/git"...
正在从"/etc/skel"复制文件...
输入新的 UNIX密码:
重新输入新的 UNIX密码:
passwd:已成功更新密码
正在改变 git的用户信息
请输入新值,或直接敲回车键以使用默认值
全名 []:
房间号码 []:
工作电话 []:
家庭电话 []:
其它 []:
这些信息是否正确? [Y/n] y
注意:记住git账户密码
1.3 创建仓库
我是在/home下创建的myreponsitory文件夹,在此文件夹下初始化一个空的MyProject.git文件夹改MyProject.git的所有权改MyProject.git的所有权zzx@zzx:~$ cd /home
zzx@zzx:/home$ ls
git zzx
zzx@zzx:/home$ sudo mkdir
myreponsitory
zzx@zzx:/home$ ls
git myponsitory zzx
zzx@zzx:/home$ cd
myreponsitory/
zzx@zzx:/home/myreponsitory$ sudo git init --bare MyProject.git
查看一下文件结构:
zzx@zzx:/home$ tree -d (需要安装tree)
.
├── git
├──myreponsitory
│ └── MyProject.git
│ ├── branches
│ ├── hooks
│ ├── info
│ ├── objects
│ │
├── info
│ │
└── pack
│ └── refs
│ ├── heads
│ └── tags
└── zzx
1.4 更改MyProject.git的权限
zzx@zzx:/home/myreponsitory$ ls -la总用量 12
drwxr-xr-x 3 root root 4096 3月 19 14:52 .
drwxr-xr-x 5 root root 4096 3月 19 14:51 ..
drwxr-xr-x 7 root root 4096 3月 19 14:52MyProject.git
zzx@zzx:/home/myreponsitory$ sudo chown -R git:gitMyProject.git
zzx@zzx:/home/myreponsitory$ ls -la
总用量 12
drwxr-xr-x 3 root root 4096 3月 19 14:52 .
drwxr-xr-x 5 root root 4096 3月 19 14:51 ..
drwxr-xr-x 7 git git 4096 3月 19 14:52MyProject.git
1.5 获取服务器的ip
zzx@zzx:$ ifconfig -a---192.168.1.106
至此,在同一局域网中搭建好git服务器。
2 客户端测试
2.1 windows测试1
在windows下安装好git,请自行搜索安装教程。2.1.1 从服务器克隆仓库
Administrator@ZZX MINGW64~ (master)$git clone git@192.168.1.106:/home/myreponsitory/MyProject.git
Cloninginto 'MyProject'...
git@192.168.1.106'spassword:
warning:You appear to have cloned an empty repository.
Checkingconnectivity... done.
2.2.2 往仓库推送内容
在MyProject文件夹中新建一个test.txt文件,随便写点内容。Administrator@ZZX MINGW64~/MyProject (master)
$git add test.txt
Administrator@ZZX MINGW64~/MyProject (master)
$git commit -m "tets"
[master(root-commit) 6a3171f] tets
1 file changed, 1 insertion(+)
create mode 100644 test.txt
Administrator@ZZX MINGW64~/MyProject (master)
$git push origin master
git@192.168.1.106'spassword:
Countingobjects: 3, done.
Writingobjects: 100% (3/3), 209 bytes | 0 bytes/s, done.
Total3 (delta 0), reused 0 (delta 0)
Togit@192.168.1.106:/home/myreponsitory/MyProject.git
* [new branch] master -> master
在windows上测试成功!
2.2 在虚拟机(ubuntu)上测试2
2.2.1 安装好git
同第一步2.2.2 输入用户名和邮箱(随便填)
git config –global user.name “aaa”git config –global user.email “aaa@163.com”
2.2.3 测试clone和push
完全同windows操作,clone下来的仓库中有刚才windows上推送上去的test.txt文件,可以自己再创建一个文件push到服务器进行测试。相关文章推荐
- Ubuntu 16.04搭建git服务器
- ubuntu 16.04 下搭建git服务器(gitosis+git-daemon+gitweb)
- Ubuntu 16.04搭建原始Git服务器
- Ubuntu 16.04搭建git服务器
- Ubuntu16.04最快捷搭建小型局域网Git服务器
- git ubuntu 16.04 服务器搭建及 git(windows使用)注意
- Ubuntu 16.04搭建原始Git服务器
- Ubuntu16.04:Git服务器搭建
- Ubuntu16.04 下搭建git服务器及gitweb+nginx配置
- Ubuntu16.04 下搭建git服务器
- ubuntu16.04 搭建git服务器简单教程
- Ubuntu16.04最快捷搭建小型局域网Git服务器
- 在ubuntu16.04搭建git服务器
- ubuntu用git-daemon搭建git服务器和配置方法
- Ubuntu中Git服务器搭建
- UbuntuServer搭建Git服务器之git和gitolite(二)
- Ubuntu10.04搭建Git服务器和GitWeb
- ubuntu 12.04 git gitosisi gitolite 服务器搭建相关汇总。
- Ubuntu下 git 服务器的搭建
- Git服务器在Ubuntu中的搭建