Gitee 分支操作说明

Gitee使用记录

新建分支

1、首先在Gitee官网新建分支,例如分支名称:redis/limind-redis。

2、远程分支创建好后,需要拉到本地。在本地目录下打开终端命令行,使用git pull命令将远程分支拉到本地。

$ git pull
From gitee.com:laoli5290/limind
 * [new branch]      redis/limind-redis -> origin/redis/limind-redis
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

3、执行git checkout redis/limind-redis命令切换分支。

$ git checkout redis/limind-redis
Switched to a new branch 'redis/limind-redis'
Branch 'redis/limind-redis' set up to track remote branch 'redis/limind-redis' from 'origin'.

4、执行git status命令查看分支状态。

$ git status
On branch redis/limind-redis
Your branch is up to date with 'origin/redis/limind-redis'.

nothing to commit, working tree clean

idea切换分支开发

ALT+F12进入Idea命令行。

合并分支

1、在特性分支(feature/limind-redis)提交代码,删除的、新加的和修改的都要提交。

$ git commit -a -m '缓存改为redis'
[feature/limind-redis 728d54a] 缓存改为redis
 14 files changed, 361 insertions(+), 1039 deletions(-)
 delete mode 100644 limind-admin/src/main/resources/ehcache/ehcache-shiro.xml
 create mode 100644 limind-common/src/main/java/com/limind/common/core/redis/RedisCache.java
 create mode 100644 limind-framework/src/main/java/com/limind/framework/config/FastJson2JsonRedisSerializer.java
 create mode 100644 limind-framework/src/main/java/com/limind/framework/config/RedisConfig.java
 delete mode 100644 limind-framework/src/main/java/com/limind/framework/shiro/service/SysShiroService.java
 delete mode 100644 limind-framework/src/main/java/com/limind/framework/shiro/session/OnlineSessionDAO.java
 delete mode 100644 limind-framework/src/main/java/com/limind/framework/shiro/web/filter/online/OnlineSessionFilter.java
 delete mode 100644 limind-framework/src/main/java/com/limind/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java
 delete mode 100644 limind-framework/src/main/java/com/limind/framework/shiro/web/session/OnlineWebSessionManager.java
 delete mode 100644 limind-framework/src/main/java/com/limind/framework/shiro/web/session/SpringSessionValidationScheduler.java
 delete mode 100644 limind-system/src/main/java/com/limind/system/mapper/SysUserOnlineMapper.java
 delete mode 100644 limind-system/src/main/java/com/limind/system/service/ISysUserOnlineService.java
 delete mode 100644 limind-system/src/main/java/com/limind/system/service/impl/SysUserOnlineServiceImpl.java
 delete mode 100644 limind-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml

2、切换到合并分支(dev)

$ git checkout dev
Switched to a new branch 'dev'
Branch 'dev' set up to track remote branch 'dev' from 'origin'.

3、合并分支

$ git merge feature/limind-redis --no-ff
# 或者
$ git merge feature/limind-redis --no-ff -m 'comment'

第一个命令需要输入合并信息,i开始插入,ESC退出,:wq保存推出命令行。

–no-ff 用于保存之前的分支历史

上一篇:Git 学习【二】 项目搭建 & 文件操作 & 使用码云 gitee & IDEA 集成 Git & 分支


下一篇:创建项目仓库②-新建远程仓库