合代码
G3 -> develop
- 切换到 develop 分支
- 拉取 develop 分支远程代码,更新到本地 develop 分支
- 拉取 G3 分支远程代码,与本地 develop 分支做合并
- 将本地 develop 分支更新后的代码,推送到远程 develop 分支
$ git checkout develop
$ git fetch origin
$ git merge origin/develop
$ git merge origin/G3
$ git push origin develop
打标签
G1
- 拉取分支
- 打 tag
- 推送 tag 到远程
$ git checkout G1
$ git fetch origin
$ git merge origin/G1
$ git tag tag_6.7.1_20191016
$ git tag -l "tag_6.7*"
$ git push origin tag_6.7.1_20191016
覆盖代码
develop -> G1
- 切换到 develop 分支
- 拉取 develop 分支远程代码,更新到本地 develop 分支
- 将本地 develop 分支更新后的代码,推送到远程 G1 分支
$ git checkout develop
$ git fetch origin
$ git merge origin/develop
$ git push origin G1 --推送不同分支需要指定本地分支名称
error: src refspec G1 does not match any
error: failed to push some refs to 'git@github.com:wow-blacksheep/saas-service-impl.git'
$ git push origin develop:G1
- 如果覆盖时,出现冲突,需要指定参数强行覆盖
$ git push origin develop:G1
To github.com:wow-blacksheep/saas-service-impl.git
! [rejected] develop -> G1 (fetch first)
error: failed to push some refs to 'git@github.com:wow-blacksheep/saas-service-impl.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git push origin develop:G1 --force
Total 0 (delta 0), reused 0 (delta 0)
To github.com:wow-blacksheep/saas-service-impl.git
+ 452eecb...aa19a52 develop -> G1 (forced update)
- 如果覆盖时,出现冲突,需要指定参数强行覆盖
覆盖时注意
- 需要先拉取被覆盖分支代码
- 看下最新节点时间,有无同事最近在该分支开发,提醒代码会被覆盖
- 打上tag,tag格式 -> "tag_6.7.1_20191016"
- 将打好的 tag 推送到远程服务端
合代码流程
先将其他分支的修复,按照版本从老到新,依次合并:
G1 -> G2 -> G3 -> develop
然后覆盖最老版本,并保持 develop 为最新版本:
develop -> G1
下一次分支合并:
G2 -> G3 -> G1 -> develop
下一次覆盖:
develop -> G2