目录
一、实验
1.环境
(1)主机
表1 主机
系统 | 架构 | 版本 | IP | 备注 |
Linux | openEuler | 22.03 LTS SP2 | 192.168.204.145(动态) 192.168.204.141(静态) 192.168.204.142(静态) | |
MySQL | 8.0.36 | |||
gogs | 0.13.0 |
(2)查看系统版本
[root@localhost ~]# cat /etc/os-release
(3) 查看网络ip
[root@localhost ~]# ip addr
(4) 查看MySQL版本
[root@localhost ~]# mysql -V
2.OpenEuler 部署 gogs
(1) 官网
https://gogs.io/
(2)源码
https://dl.gogs.io/
最新版本为0.13.0
(3)下载
wget https://dl.gogs.io/0.13.0/gogs_0.13.0_linux_amd64.zip
(4)解压
[root@localhost opt]# unzip gogs_0.13.0_linux_amd64.zip
(5)查看git
已安装
[root@localhost ~]# sudo dnf install -y git
(6)添加git用户
useradd git
chown -R git:git /opt/gogs
mkdir -p /home/git/gogs-repositories
chown -R git:git /home/git/gogs-repositories
(7) MySQL数据库创建Gogs数据库及用户
[root@localhost ~]# mysql -uroot -p
……
mysql> CREATE DATABASE gogs CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected, 2 warnings (0.02 sec)
mysql> CREATE USER 'gogs'@'localhost' IDENTIFIED BY 'gogs';
Query OK, 0 rows affected (0.02 sec)
mysql> GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
(8) 启动
cd /optgogs
./gogs web
(9)配置
浏览器访问
http://localhost:3000/install
修改配置
(10) 进入系统
3.OpenEuler 使用 gogs
(1)创建新仓库
完成
(2)创建密钥
[root@localhost .ssh]# ssh-keygen -t rsa -b 4096 -C "7jjw@163.com"
[root@localhost .ssh]# ls
id_rsa id_rsa.pub
[root@localhost .ssh]# cat id_rsa.pub
# 将密钥添加到gogs上
(3)添加密钥
完成
(4)操作仓库
# 克隆仓库
git clone http://localhost:3000/administrator/test.git
# 执行初始操作
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin http://localhost:3000/administrator/test.git
git push -u origin master
(5)查看仓库
已更新
二、问题
1.数据库设置不正确
(1)报错
(2)原因分析
数据库配置错误。
(3)解决方法
修改数据库配置。
修改前:
修改后:
2.管理员账户设置不正确
(1)报错
(2)原因分析
管理员账户不能使用admin
(3)解决方法
修改管理员账户。
修改前:
修改后:
3.git 初始化报错
(1)报错
[root@localhost ~]# git init
提示:使用 'master' 作为初始分支的名称。这个默认分支名称可能会更改。要在新仓库中
提示:配置使用初始分支名,并消除这条警告,请执行:
提示:
提示: git config --global init.defaultBranch <名称>
提示:
提示:除了 'master' 之外,通常选定的名字有 'main'、'trunk' 和 'development'。
提示:可以通过以下命令重命名刚创建的分支:
提示:
提示: git branch -m <name>
(2)原因分析
未设置默认分支。
(3)解决方法
置默认分支。
[root@localhost ~]# git config --global init.defaultBranch master
成功:
4.git commit 提示
(1)提示
[root@localhost ~]# git commit -m "first commit"
[master(根提交) dbefc8a] first commit
Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以对其进行设置以免再出现本提示信息:
git config --global user.name "Your Name"
git config --global user.email you@example.com
设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:
git commit --amend --reset-author
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.md
(2)原因分析
未设置全局用户及邮箱。
(3)解决方法
设置全局用户及邮箱。
git config --global user.name "Your Name"
git config --global user.email you@example.com