centos git版本服务器配置

news/2024/7/4 1:32:02 标签: git, 运维, python
centos git版本服务器配置

在服务器上安装git及做些操作

 

- 执行命令
`
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
`
 - 同时下载git-1.8.2.3.tar.gz文件,
wget https://www.kernel.org/pub/software/scm/git/git-1.8.2.3.tar.gz

sudo tar -zvxf git-1.8.2.2.tar.gz
cd git-1.8.2.2

sudo make prefix=/usr/local/git all
sudo make prefix=/usr/local/git install

```

 - 增加软连接
```
sudo ln -s /usr/local/git/bin/* /usr/bin/

git --version  #如果能显示版本号,即表示成功`

```

3.在服务器安装gitosis
```
sudo yum install python python-setuptools

cd /usr/local/src

git clone git://github.com/res0nat0r/gitosis.git

cd gitosis

python setup.py install  

#显示Finished processing dependencies for gitosis==0.2即表示成功

```


4.在开发机上,生产密钥并上传到服务器上
```
ssh-keygen -t rsa   #一路回车,不需要设置密码

#上传公钥到服务器(默认SSH端口22)
scp ~/.ssh/id_rsa.pub tailin@192.168.100.202:/tmp
```

或编辑`/etc/hosts`文件,在`/etc/hosts`文件里添加如下文本:
```
# local git server
192.168.100.202 zgit
```
然后再上传自己的公钥到服务器
```
scp ~/.ssh/id_rsa.pub tailin@zgit:/tmp/

# 登录到git服务器
ls /tmp/id_rsa.pub  #显示已经上传的密钥

```

5.服务器上生成git用户,使用git用户并初始化`gitosis`

```
# 创建git版本管理用户 git
sudo useradd -c 'git version manage' -m -d /home/git -s bin/bash  git

# 更改git用户的密码
sudo passwd git

# su 到git用户
su - git
gitosis-init < /tmp/id_rsa.pub

#显示以下信息即表示成功
#Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
#Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/

#删除密钥
rm -rf /tmp/id_rsa.pub

```

6.在个人开发机上导出项目管理
```
mkdir -p /repo
cd /repo
git clone git@zgit:gitosis-admin.git

```

7.在个人开发机增加及设置管理项目
```
cd /repo/gitosis-admin

# 查看git服务器已经上传密钥
ls keydir  

cat keydir/ltl@jackliu-ThinkPad.pub  

#ltl@jackliu-ThinkPad.pub为已经上传的开发机生成的公密

#显示密钥 最后的字符串为 密钥用户名 这里为 ltl@jackliu-ThinkPad
vim gitosis.conf

#在文件尾增加以下内容

[group test-git]            # 具有写权限的组名称
writable = test-git         # 该组可写的项目名称
members = ltl@jackliu-ThinkPad  guangyun.ni@yeepay.com     #该组的成员(密钥用户名) 多个用户协同开发时,以空格分隔

# 如果要增加只读的组 参考如下
# [group test-git-readnoly]          # 具有都权限的组名称
# readonly = test-git                # 该组只读的项目名称
# members = ltl@jackliu-ThinkPad     # 该组的成员


#提交修改
git add .
git commit -a -m "add test-git repo"
git push

```

8.在个人开发机上初始,增加及使用项目test-git

```
cd ~/repo  

mkdir test-git   

cd test-git  

git init  

touch readme  

git add .   

git commit -a -m "init test-git"  

git remote add origin git@zgit:test-git.git  

git push origin master  

```

9.增加协同开发者的公钥key到git服务器  
 
 - 执行`cd repo/gitosis-admin/keydir`切换目录
 
 - 把协同开发者的id_rsa.pub 文件里的数据 拷贝到 对应的开发者的`密钥用户名.pub`文件。如把密钥用户名 guangyun.ni@yeepay.com 的 id_rsa.pub 文件中文本 粘贴到 guangyun.ni@yeepay.com.pub 文件里,并保存

 - 然后将添加数据后的目录更新到git服务器
 
 ```
 
 git add .  
 git commit -am "add guangyun.ni@yeepay.com.pub file"  
 git push origin master  
 
 ```
posted on 2014-04-13 10:22 秦瑞It行程实录 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/ruiy/p/git.html


http://www.niftyadmin.cn/n/1798850.html

相关文章

leetcode(100):Same Tree

题目&#xff1a;Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. 题目分析&#xff1a;判断二棵树是否相同&#xff0…

裁剪图片中遇到问题,怎么解决?

2019独角兽企业重金招聘Python工程师标准>>> 问题代码&#xff1a; Intent cropIntent new Intent("com.android.camera.action.CROP");cropIntent.setType("image/*");cropIntent.putExtra("crop", "true");cropIntent.p…

POJ 1847 最短路问题 dijkstra算法的实现

首先自己练习了一下实现dijkstra算法&#xff0c;可以把dj算法与prim算法对比记忆,要理解pre数组、min数组、V标记数组的含义&#xff01; //单源最短路径,dijkstra算法,邻接阵形式,复杂度O(n^2)//求出源s到所有点的最短路经,传入图的顶点数n,(有向)邻接矩阵mat//返回到各点最…

leetcode(101):Symmetric Tree

题目&#xff1a;Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). 对于题目的分析&#xff1a;这个题目要求判断给定的这棵树是不是关于根节点对称。对于根节点而言&#xff0c;首先需要判断根节点是不是为None形式&#…

消除云界限——NetApp更新高端存储

云本身就是无形的、灵动的。但是借用了“云”概念的计算却非要分清到底是公有、私有还是混合。 如今&#xff0c;人们又在想方设法消除公有云、私有云和混合云之间的界限&#xff0c;让数据和应用能够在“自由云域”中畅行。无论是公有云、私有云还是混合云&#xff0c;它们对于…

linux上部署nodejs

linux上部署nodejs 环境&#xff1a;# lsb_release -aLSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarchDistributor ID: CentOSDescript…

leetcode(617):Merge Two Binary Trees

题目要求&#xff1a; Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two no…

POJ 1247 数组首尾求和判定相等 枚举法

此题把题意弄懂后就很容易&#xff0c;S顺时针走&#xff0c;E逆时针走&#xff0c;确定一个分割点该处两人相遇时途经的客人数之和相等&#xff0c;直接枚举。 #include <iostream> using namespace std; //s顺时针走&#xff0c;e逆时针走&#xff0c;问他们在哪里相遇…