Gitlab-项目创建

40 篇文章 0 订阅
7 篇文章 0 订阅
本文详细介绍了如何从零开始搭建Gitlab,包括用户创建、项目创建、SSH密钥配置、本地项目初始化及推送,以及遇到的问题与解决办法。此外,还涵盖了分支管理、权限保护、项目删除、组删除和成员管理等关键步骤,是Gitlab使用者的全面指南。
摘要由CSDN通过智能技术生成

一、Gitlab搭建

若无本地Gitlab,参考教程:https://blog.csdn.net/weixin_41668084/article/details/113817655

二、用户创建

若已有用户,直接登录,若无用户创建新的用户

2.1 登录用户

image-20210216131828626

2.2 创建新的用户

image-20210216132054781

2.3 登录初始页面

image-20210216132934970

三、项目创建

3.1 创建群组

image-20210216133544217 image-20210216133859781

3.2 创建项目

image-20210216133951553 image-20210216134114249

3.3 添加SSH密钥

密钥生成可参考教程:https://blog.csdn.net/weixin_41668084/article/details/113820287

image-20210216134213292 image-20210216134521231

3.4 本地创建项目

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.jenkins</groupId>
    <artifactId>gitlab</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>gitlab</name>
    <description>jenkins-gitlab project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-boot.version>2.3.7.RELEASE</spring-boot.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <finalName>jenkins-gitlab</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.7.RELEASE</version>
                <configuration>
                    <mainClass>com.jenkins.gitlab.GitlabApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

3.5 项目初始化

3.5.1 Git局部配置
#切换到项目路径下
git init
git config --local user.name "你的名称"
git config --local user.email "你的邮箱"
#查看本地信息
git config --local --list
3.5.2 项目推送
#连接远程仓库
git remote add origin http://192.168.61.72/test/gitlab-test.git
#添加所有文件
git add .
#提交代码
git commit -m "Initial commit"
#推送远程仓库
git push -u origin master
image-20210216141319572
3.5.3 项目推送失败
3.5.3.1 问题现状
#git客户端使用ssh秘钥登录GitLab时提示permission denied please try again
git@192.168.61.72: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
3.5.3.2 问题解决
vi /etc/ssh/sshd_config
去掉注释 #
保存退出(Esc+:wq!)
重启ssh服务
service sshd restart
image-20210220170345804 image-20210220170707667

3.6 创建分支

image-20210216142409005 image-20210216142516258

3.7 分支保护

image-20210216142814735 image-20210216143030889

3.8 项目删除

image-20210216132540240

3.9 组删除

image-20210216132706876

3.10 成员添加

image-20210216143223346

以上,请参考!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要使用 `gitlab-rake` 创建备份,您需要先安装 GitLab CE 或者有权限运行命令的 GitLab EE。在 Linux 或 macOS 上,通常可以通过包管理器安装 `gitlab-rake`,而在 Windows 上可能需要从 GitLab 官方下载并安装。 下面是如何通过 `gitlab-rake` 命令创建备份的示例: ### 步骤 1: 安装 GitLab 如果您还没有安装 GitLab,您可以访问 GitLab 官网(https://about.gitlab.com/download/)下载适合您的操作系统的安装程序。 ### 步骤 2: 初始化 GitLab 一旦安装了 GitLab,启动服务器并初始化配置。这通常涉及设置密码和其他安全参数。 ```bash # 启动 GitLab 服务器 sudo service gitlab-runner start # 初始化配置文件 sudo gitlab-rake db:migrate RAILS_ENV=production ``` ### 步骤 3: 执行备份任务 为了执行 `gitlab:backup:create` 命令以创建数据库备份,确保已正确配置 GitLab 并具有相应的权限。然后,按照以下步骤操作: ```bash # 进入项目目录(如果是在特定项目下运行) cd /path/to/your/gitlab/project # 切换到生产环境 RAILS_ENV=production bundle exec gitlab-rake gitlab:backup:create ``` 这将会创建一个名为 `backup.sql.gz`(或根据配置的命名约定)的压缩文件,位于指定的备份目录下,默认路径通常是 `/var/opt/gitlab/backups/`。 ### 注意事项: - **备份位置**:确保备份目录存在并且拥有正确的读写权限。 - **备份频率**:根据需求定期执行备份任务。 - **恢复过程**:要从备份恢复数据库,可以使用 `gitlab-rake db:restore` 命令,并指定备份文件的位置和名称。 --- ### 相关问题 - 示例: 1. 如何自定义 GitLab 备份文件的命名和存储位置? 2. 如何监控 GitLab 备份状态和历史记录? 3. 是否可以在 GitLab 外部的机器上运行 `gitlab-rake` 命令来执行备份?
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值