环境介绍
- 服务器是Ubuntu环境,在阿里云买的远程服务器,远程操控
准备工作
- 安装git,
sudo apt install git - git版本,如图:

- window端安装这里就不做赘述了。
安装
-
添加用户组和用户
# 创建用户组git sudo groupadd git # 这里-m是创建文件夹,-g是分到git组里 sudo useradd -m git -g git # 更改密码,更改成自己的密码 sudo passwd git -
切换用户,初始化我们的仓库,仓库的名称一般都是以
.git为后缀的# 切换git用户,输入自己的设置的密码 su - git # 初始化我们的仓库,名字可以自己起 git init --bare project.git # pwd查看自己的仓库的路径,方便客户端下载 pwd -
在客户端(我的是window)上进行连接
# 这里的xxx是服务器上的ip地址,冒号后面是你project.git的绝对路径,pwd显示的路径。 git clone git@xxx:/home/gitpro/project.git -
在客户端如果输入命令
git branch没有任何分支,可以用下面的方法来获得master分支# 如果不懂下面的方法的含义,就去学一下git命令,网上很多 git add . git commit -m "aa"用完上面的命令之后就会有一个master分支,后面就是常规的git命令使用。
-
gitweb的安装
- 准备工作
sudo apt-get install openssh-server openssh-client git gitweb apache2 - git初始化上面已经完成这里就不在写了,如果你没有初始化就再初始化一遍
git init --bare project.git - 在服务器端配置git仓库的目录路径(这个目录可以存放多个git服务端仓库,会一起在网页中加载),修改/etc/gitweb.conf文件中projectroot参数,eg:
$projectroot = "/home/<username>/<gitlibrary>"; - apache2配置,这里要分为两种情况,
如果在/etc/apache2/apache2.conf文件中的部分代码是下面这样,就不需要更改
如果部分代码如下面的代码就要:# Include module configuration: Include mods-enabled/*.load Include mods-enabled/*.conf # Include all the user configurations: Include httpd.conf # Include ports listing Include ports.conf # Include generic snippets of statements Include conf.d/ # Include the virtual host configurations: Include sites-enabled/
执行下面的命令# Include module configuration: IncludeOptional mods-enabled/*.load IncludeOptional mods-enabled/*.conf # Include generic snippets of statements IncludeOptional conf-enabled/*.conf # Include the virtual host configurations: IncludeOptional sites-enabled/*.conf
当然你可以去/etc.apache2/conf-available目录下有没有gitweb.conf这个文件,如果有,上面都不需要做sudo cp /etc/apache2/conf.d/gitweb /etc/apache2/conf-available/gitweb.conf - 重启服务
sudo service apache2 restart sudo a2enmod cgid - 访问自己的网址
如图:http://自己的ip地址/gitweb/
- 准备工作
本文详细介绍了如何在Ubuntu服务器上安装和配置Git仓库,包括创建用户组和用户,初始化仓库,以及在Windows客户端连接仓库。此外,还讲解了如何安装和配置Gitweb以实现仓库的Web界面管理,包括Apache2的配置和访问仓库的URL。
5447

被折叠的 条评论
为什么被折叠?



