tags" href="/tags/GIT.html" title=git>git_0">一、tags" href="/tags/GIT.html" title=git>git创建分支并克隆指定分支到本地
tags" href="/tags/GIT.html" title=git>gitee官网:https://tags" href="/tags/GIT.html" title=git>gitee.com/
登录上tags" href="/tags/GIT.html" title=git>gitee账号,我这用testtags" href="/tags/CangKu.html" title=仓库>仓库作测试。新建分支名称为develop,分支起点选择master,创建即可,如下图所示:
使用tags" href="/tags/GIT.html" title=git>git管理代码版本时,本地分支默认与远程同名分支建立追踪关系。tags" href="/tags/GIT.html" title=git>git clone 命令默认将整个远程版本库克隆到本地,但是tags" href="/tags/GIT.html" title=git>git clone -b [分支名称]命令可以将指定的一个远程分支克隆到我们本地,而且克隆的本地分支自动和远程同名分支建立追踪关系,它不会将新创建的HEAD指向克隆tags" href="/tags/CangKu.html" title=仓库>仓库中HEAD指向的maser主分支,而是指向刚克隆下来的分支。
克隆tags" href="/tags/GIT.html" title=git>gitee上的testtags" href="/tags/CangKu.html" title=仓库>仓库中的develop分支,如下图所示:
tags" href="/tags/GIT.html" title=git>git clone -b [分支名称] [tags" href="/tags/GIT.html" title=git>gitee上tags" href="/tags/CangKu.html" title=仓库>仓库https链接]
tags" href="/tags/GIT.html" title=git>gitee_16">二、本地分支打标签并上传到码云(tags" href="/tags/GIT.html" title=git>gitee)远程tags" href="/tags/CangKu.html" title=仓库>仓库对应的远程标签
1.tag标签基础知识
tag标签就是对某次 commit 的一个标识,相当于起了一个别名。
tag格式:v主版本号.次版本号.修订号_类型标签,其中类型标签可为:alpha、beta、rc、release。
tag示例:v1.0.0_alpha、v1.0.0_release
修订号后面可以添加发布日期,tag示例:v1.0.0.230910_release
1.1 直接列出所有的标签:
tags" href="/tags/GIT.html" title=git>git tag
1.2 查看标签的提交信息:
tags" href="/tags/GIT.html" title=git>git show 标签名
1.3 创建附注标签:
-a
: 理解为 annotated
的首字符,表示 附注标签
-m
: 指定附注信息
tags" href="/tags/GIT.html" title=git>git tag -a 标签名 -m 附注信息
1.4 删除标签
tags" href="/tags/GIT.html" title=git>git tag -d 标签名
1.5 将指定的标签上传到远程tags" href="/tags/GIT.html" title=git>giteetags" href="/tags/CangKu.html" title=仓库>仓库
tags" href="/tags/GIT.html" title=git>git push origin 标签名
1.6 删除tags" href="/tags/GIT.html" title=git>gitee上指定的远程标签,可以在tags" href="/tags/GIT.html" title=git>gitee上图形化操作。
2.branch分支基础知识
branch分支: 四个环境(开发、测试、灰度、生产),分支与版本关系如下:
dev-->alpha 开发环境
test-->beta 测试环境
pre-->rc 灰度环境
master-->release 生产环境
2.1 查看本地分支
tags" href="/tags/GIT.html" title=git>git branch
2.2 查看远程分支
tags" href="/tags/GIT.html" title=git>git branch -a
2.3 创建分支
tags" href="/tags/GIT.html" title=git>git branch 分支名
//仅仅保存在本地,将本地当前分支推送到 远程指定分支上,还需要push,如下:
tags" href="/tags/GIT.html" title=git>git push origin [远程分支名]
2.4 删除本地分支
tags" href="/tags/GIT.html" title=git>git branch -d 分支名
2.5 删除tags" href="/tags/GIT.html" title=git>gitee上的指定的远程分支,可以在tags" href="/tags/GIT.html" title=git>gitee上图形化操作。
2.6 切换分支
tags" href="/tags/GIT.html" title=git>git checkout 分支名
2.7 创建并切换分支
tags" href="/tags/GIT.html" title=git>git checkout -b 分支名
3.本地分支打标签并上传到码云(tags" href="/tags/GIT.html" title=git>gitee)远程tags" href="/tags/CangKu.html" title=仓库>仓库对应远程标签
tags" href="/tags/GIT.html" title=git>git tag -a 标签名 -m 附注信息
tags" href="/tags/GIT.html" title=git>git add .
tags" href="/tags/GIT.html" title=git>git commit -am “提交日志描述”
tags" href="/tags/GIT.html" title=git>git push origin 标签名
在tags" href="/tags/GIT.html" title=git>gitee上可以看到已上传的标签
tags" href="/tags/GIT.html" title=git>gitee_112">三、本地分支上传到码云(tags" href="/tags/GIT.html" title=git>gitee)远程tags" href="/tags/CangKu.html" title=仓库>仓库对应远程分支
tags" href="/tags/GIT.html" title=git>git add .
tags" href="/tags/GIT.html" title=git>git commit -am “提交日志描述”
tags" href="/tags/GIT.html" title=git>git push origin 分支名
下面是将本地delelop分支上传的到tags" href="/tags/GIT.html" title=git>gitee远程delelop分支
在tags" href="/tags/GIT.html" title=git>gitee上可以看到已上传的develop分支更新
tags" href="/tags/GIT.html" title=git>gitee_130">四、本地分支合并到主分支,主分支打标签并上传到码云(tags" href="/tags/GIT.html" title=git>gitee)远程tags" href="/tags/CangKu.html" title=仓库>仓库对应的远程标签
4.1确认当前位于要合并到主分支的分支上。如果不是,请使用 tags" href="/tags/GIT.html" title=git>git checkout 命令切换到该master分支
切换分支
tags" href="/tags/GIT.html" title=git>git checkout 分支名
创建并切换分支
tags" href="/tags/GIT.html" title=git>git checkout -b 分支名
4.2把远程master主分支克隆到本地
tags" href="/tags/GIT.html" title=git>git clone -b master [tags" href="/tags/GIT.html" title=git>gitee上tags" href="/tags/CangKu.html" title=仓库>仓库https链接]
4.3 如果没有冲突,则可以使用 tags" href="/tags/GIT.html" title=git>git merge 命令将分支合并到主分支中
tags" href="/tags/GIT.html" title=git>git merge 分支名
4.4 主分支打标签并上传到码云(tags" href="/tags/GIT.html" title=git>gitee)远程tags" href="/tags/CangKu.html" title=仓库>仓库对应的远程标签
tags" href="/tags/GIT.html" title=git>git tag -a 标签名 -m 附注信息
tags" href="/tags/GIT.html" title=git>git add .
tags" href="/tags/GIT.html" title=git>git commit -am “提交日志描述”
tags" href="/tags/GIT.html" title=git>git push origin 标签名
在tags" href="/tags/GIT.html" title=git>gitee上可以看到已上传的标签
tags" href="/tags/GIT.html" title=git>gitee_167">五、本地主分支上传到码云(tags" href="/tags/GIT.html" title=git>gitee)远程tags" href="/tags/CangKu.html" title=仓库>仓库对应远程分支
tags" href="/tags/GIT.html" title=git>git add .
tags" href="/tags/GIT.html" title=git>git commit -am “提交日志描述”
tags" href="/tags/GIT.html" title=git>git push origin master
下面是将本地master主分支上传到tags" href="/tags/GIT.html" title=git>gitee远master主分支
在tags" href="/tags/GIT.html" title=git>gitee上可以看到已上传的主分支更新