综合项目1-04 分布式版本管理gitee

7. 版本管理

7.1 版本管理背景

       SVN团队代码同步与版本管理:公司SVN服务器,开发人员每台一个SVN客户端或作为插件放到idea中即可实现版本提交与同步。为了解决离开公司内网也可以提交,出现了分布式版本管理。即当客户端提交时先把代码提交到本地管理的仓库里,即本地就具备了服务器版本管理的功能,若确定要提交到服务器再push到公司的服务器上进行共享。其他人就可以pull下来你的代码以实现共享。同样的方式,对方电脑上也有一个本地管理仓库里,记录下你代码的版本,与pull拉取下来的代码版本作比对更新。

        通过分布式版本管理,实现了每个人本地都有一个版本库。从原来的commit直接到服务器变成了先commit到本地库,再通过push推送到服务器。即git的原型。

综合项目1-04 分布式版本管理gitee

 

7.2 Gitee安装与使用

      先安装git软件,安装成功后即出现git客户端,git bash可以直接使用linux命令进行操作

综合项目1-04 分布式版本管理gitee

      在idea中配置git本地安装目录

综合项目1-04 分布式版本管理gitee

      在idea中安装gitee插件

综合项目1-04 分布式版本管理gitee

再到gitee中申请账号,并在idea中增加登录帐号:

综合项目1-04 分布式版本管理gitee

初次提交

综合项目1-04 分布式版本管理gitee

综合项目1-04 分布式版本管理gitee

综合项目1-04 分布式版本管理gitee

综合项目1-04 分布式版本管理gitee

在本地就生成了一个本地管理库

综合项目1-04 分布式版本管理gitee

 

7.3 从远程Gitee拉取创建项目

综合项目1-04 分布式版本管理gitee

找到项目仓库,复制地址

综合项目1-04 分布式版本管理gitee

再到本地粘贴

综合项目1-04 分布式版本管理gitee

综合项目1-04 分布式版本管理gitee

完成项目本地拉取

 

7.4 修改代码与提交

 

7.4.1、将web作为module

7.4.1.1 修改web的pom文件,将其parent改为父项目,并将版本补齐

<parent>
    <
artifactId>cooperation</artifactId>
    <
groupId>pub.ryan</groupId>
    <
version>1.0-SNAPSHOT</version>
</
parent>
<
modelVersion>4.0.0</modelVersion>
<
artifactId>co_web</artifactId>
<
description>Demo project for Spring Boot</description>

<
properties>
    <
java.version>1.8</java.version>
    <
spring.version>2.3.5.RELEASE</spring.version>
</
properties>

<
dependencies>
    <
dependency>
        <
groupId>org.springframework.boot</groupId>
        <
artifactId>spring-boot-starter-web</artifactId>
       
<version>${spring.version}</version>
    </dependency>

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

<
build>
    <
plugins>
        <
plugin>
            <
groupId>org.springframework.boot</groupId>
            <
artifactId>spring-boot-maven-plugin</artifactId>
           
<version>${spring.version}</version>
        </plugin>
    </
plugins>
</
build>

7.4.1.2 在父pom中加入module

<modules>
    <
module>dataware</module>
    <
module>userprofile</module>
    <
module>recommend</module>
    <
module>commons</module>
   
<module>co_web</module>
</modules>

此时,maven中就只有一个root父项目,其它都是module

综合项目1-04 分布式版本管理gitee 

7.4.2 提交修改与回滚版本

7.4.2.1 提交到本地 

综合项目1-04 分布式版本管理gitee

改过的多就选整个目录,改的少就直接勾选改过的文件即可,并写提交说明 

综合项目1-04 分布式版本管理gitee

7.4.2.2  将本地改动push到远程服务器

综合项目1-04 分布式版本管理gitee 综合项目1-04 分布式版本管理gitee

综合项目1-04 分布式版本管理gitee

远程即可看到改过的代码及提交说明

综合项目1-04 分布式版本管理gitee

综合项目1-04 分布式版本管理gitee

7.4.2.3  回滚版本及修改Rollback Changes

综合项目1-04 分布式版本管理gitee