创建发布分支:

(1) 软件hello-world的1.0发布版本库中有一个里程相对应.

/home/jackluo/workspace/user1/workspace/hello-world
git tag -n1 -l v*

(2)基于里程v1.0创建发布布hello-1.x.

注:使用了git checkout 命令创建分支,最后一个参数v1.0是新分支 hello-1.x创建的基准点,如果没有里程,使用提交ID也是一样

[root@localhost hello-world]# git tag -n1 -l v*
v1. Release 1.0
[root@localhost hello-world]# git checkout -b hello-x.x v1.
切换到一个新分支 'hello-x.x'

(3)用git rev-parse 命令可以看到hello-1.x分支对应的提交ID和里程v1.0指向的提交一致,但是和master不一样

提示:因为里程v1.0是一个包含提交说明的里程,因此为了显示其对应的提交ID,使用特别的记法 "v1.0^{}".

[root@localhost hello-world]# git rev-parse hello-x.x v1.^{} master
d901dd8170f67fec607828905d5fbd91e3272400
d901dd8170f67fec607828905d5fbd91e3272400
733dcf67eba976a61d0dc6396c9d23cb23568591

(4)开发者user1将分支hello-1.x推送到远程 共享版本库,因为开发者user2修改Bug时也要用到该分支

[root@localhost hello-world]# git push origin hello-x.x
Total (delta ), reused (delta )
To /home/jackluo/workspace/repos/hello-world.git
* [new branch] hello-x.x -> hello-x.x

(5).开发者user2 从远程共享版本库获取新的分支。

开发者user2执行git fetch命令,将远程共享版本库的新分支hello-1.x复制到本地引用origin/hello-1.x上.

[root@localhost hello-world]# cd ../../../user2/workspace/hello-world/
[root@localhost hello-world]# git fetch
remote: Counting objects: , done.
remote: Compressing objects: % (/), done.
remote: Total (delta ), reused (delta )
Unpacking objects: % (/), done.
来自 /home/jackluo/workspace/repos/hello-world
* [新分支] hello-x.x -> origin/hello-x.x
d901dd8..733dcf6 master -> origin/master

(6).开发者user2切换到hello-x.x分支.

[root@localhost hello-world]# git checkout -b hello-x.x origin/hello-x.x
分支 hello-x.x 设置为跟踪来自 origin 的远程分支 hello-x.x。
切换到一个新分支 'hello-x.x'

(1)编辑文件src/main.c,将"--help"字符串修改为"--help".

[root@localhost hello-world]# cd ../../../user1/workspace/hello-world/
[root@localhost hello-world]# vim src/main.c

(2)开发者user1的改动可以从下面的差异比较中看到.

[root@localhost hello-world]# git diff

(3) 执行提交

[root@localhost hello-world]# git add -u
[root@localhost hello-world]# git commit -m "Fix typo: -help to --help."
[hello-x.x ca43043] Fix typo: -help to --help.
file changed, insertions(+), deletions(-)

(4).推送到远程共享版本库.

[root@localhost hello-world]# git push
warning: push.default 未设置,它的默认值将会在 Git 2.0 由 'matching'
修改为 'simple'。若要不再显示本信息并在其默认值改变后维持当前使用习惯,
进行如下设置: git config --global push.default matching 若要不再显示本信息并从现在开始采用新的使用习惯,设置: git config --global push.default simple 参见 'git help config' 并查找 'push.default' 以获取更多信息。
('simple' 模式由 Git 1.7. 版本引入。如果您有时要使用老版本的 Git,
为保持兼容,请用 'current' 代替 'simple' 模式) Counting objects: , done.
Delta compression using up to threads.
Compressing objects: % (/), done.
Writing objects: % (/), bytes | bytes/s, done.
Total (delta ), reused (delta )

开发者user2工作在发布分支.

(1)进入开发者user2的工作区,并确保工作在hello-x.x分支中

[root@localhost hello-world]# cd ../../../user2/workspace/hello-world/
[root@localhost hello-world]# git checkout hello-x.x
已经位于 'hello-x.x'

(2)编辑文件 src/mai.c,修改代码中的Bug.

[root@localhost hello-world]# vim src/main.c
[root@localhost hello-world]# git format-path jx/v1...jx/v1.
git:'format-path' 不是一个 git 命令。参见 'git --help'。 您指的是这个么?
format-patch
[root@localhost hello-world]# git format-patch jx/v1...jx/v1.
-Bugfix-allow-spaces-in-username.patch
[root@localhost hello-world]# patch -p1 < -Bugfix-allow-spaces-in-username.patch
patching file src/main.c
[root@localhost hello-world]# git diff
[root@localhost hello-world]# cd src/
[root@localhost src]# ll
总用量
-rw-r--r-- root root 1月 : main.c
-rw-r--r-- root root 12月 : Makefile
-rw-r--r-- root root 12月 : version.h.in
[root@localhost src]# make
version.h.in => version.h
cc -c -o main.o main.c
cc -o hello main.o
[root@localhost src]# ./hello Jack Luo
Hi, Jack Luo.
(version: v1.-dirty)
[root@localhost src]# git add -u
[root@localhost src]# git commit -m "Bugfix: allow spaces in username."
[hello-x.x 0ad2a9e] Bugfix: allow spaces in username.
file changed, insertions(+), deletion(-)

开发者user2合并推送

开发者user2在本地版本完成提交后,

[root@localhost src]# git pull
Already up-to-date.
[root@localhost src]# git log --graph --oneline
[root@localhost src]# cd ..
[root@localhost hello-world]# git checkout master
切换到分支 'master'
您的分支落后 'origin/master' 共 个提交,并且可以快进。
(使用 "git pull" 来更新您的本地分支)
[root@localhost hello-world]# git pull
更新 d901dd8..733dcf6
Fast-forward
src/Makefile | ++-
src/main.c | ++++++++++++++++++++++++++++++++++++-----
files changed, insertions(+), deletions(-)
[root@localhost hello-world]# git pull
Already up-to-date.
[root@localhost hello-world]# git push
Everything up-to-date
[root@localhost hello-world]# git checkout master
已经位于 'master'

发布分支的提交合并到主线.

1.操作

查看分支 hello-1.x的日志,确认要提交的ID.

从下面的日志中可以看出分支hello-1.x 的最新提交是一个合并提交,可以分别用"hello-1.x^1和"hello-1.x^2"表示

[root@localhost hello-world]# git pull
Already up-to-date.
[root@localhost hello-world]# git log - --graph --oneline hello-x.x
* 9cc4e7b Merge branch 'hello-x.x' of /home/jackluo/workspace/repos/hello-worl
|\
| * ca43043 Fix typo: -help to --help.
* | 0ad2a9e Bugfix: allow spaces in username.

(5)操作发生冲突,通过查看状态可以看到是在文件src/main.c上发生了冲突.

[root@localhost hello-world]# git status
# 位于分支 master
# 您正在做拣选操作。
# (解决冲突并运行 "git cherry-pick --continue")
# (使用 "git cherry-pick --abort" 以取消拣选操作)
#
# 未合并的路径:
# (使用 "git add <file>..." 标记解决方案)
#
# 双方修改: src/main.c
#
# 未跟踪的文件:
# (使用 "git add <file>..." 以包含要提交的内容)
#
# -Bugfix-allow-spaces-in-username.patch
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost hello-world]# git status
# 位于分支 master

2.冲突发生的原因,通过下面的命令可以看到底是哪些提交引起的冲突.

[root@localhost hello-world]# git log master...hello-x.x^
commit 0ad2a9e90213aca2d882ba6fa49d4667db5e2106
Author: user2 <user2@sun.ossxp.com>
Date: Thu Jan :: + Bugfix: allow spaces in username. commit 733dcf67eba976a61d0dc6396c9d23cb23568591
Author: user1 <user1@sun.ossxp.com>
Date: Thu Jan :: + Refactor: use getopt_long for arguments parsing.

3.冲突解决

git 基于发布分支的开发的更多相关文章

  1. git基于某个分支创建分支

    1.git checkout -b 新分支名 老分支名 git checkout -b dev_20150909 master git ls -tree 分支名字

  2. git 基于某个分支创建分支

    1.拷贝源代码 git clone git@git地址 cd 项目目录 2.根据已有分支创建新的分支 git checkout -b yourbranchname origin/oldbranchna ...

  3. Jenkins+.Net Core+Git集成发布 - SkyMallCore快速开发平台

    准备工作:安装 Jenkins+java 直接百度安装,在此忽略 dotnet sdk(iis部署已经安装) 一:windows 部署到IIS 首先搭建IIS,站点应用程序池选择 ‘无托管代码’ 安装 ...

  4. GitHub Flow & Git Flow 基于Git 的两种协作开发模式

    介绍基于Git 两种协作开发模式,GitHub Flow & Git Flow 对于Github 一些好用的特殊操作技巧 ,可以见GitHub 特殊操作技巧 和Git的基本操作 一 GitHu ...

  5. Git 分支-利用分支进行开发的工作流程

    3.4 Git 分支 - 利用分支进行开发的工作流程 利用分支进行开发的工作流程 现在我们已经学会了新建分支和合并分支,可以(或应该)用它来做点什么呢?在本节,我们会介绍一些利用分支进行开发的工作流程 ...

  6. git多人协作式开发时分支管理策略

    什么是 git-flow? Git Flow是一套使用Git进行源代码管理时的一套行为规范 主分支Master 首先,代码库应该有一个.且仅有一个主分支.所有提供给用户使用的正式版本,都在这个主分支上 ...

  7. git如何利用分支进行多人开发

    在使用git时,假如远程仓库有 dev 和 master 两个分支,master 作为一个稳定版分支,可用于直接发布产品,日常的开发则 push 到 dev 分支,那本地是不是要从 dev 分支中创建 ...

  8. git 操作 :从远程仓库gitLab上拉取指定分支到本地仓库;git如何利用分支进行多人开发 ;多人合作代码提交实践

    例如:将gitLab 上的dev分支拉取到本地 git checkout -b dev origin/dev 在本地创建分支dev并切换到该分支 git pull origin dev 就可以把git ...

  9. 怎么查看当前的git分支是基于哪个分支创建的?

    2019独角兽企业重金招聘Python工程师标准>>> Question: 比如从 branch A 切出一个 branch B 然后对branch B做了一系列的操作 然后忘记了b ...

随机推荐

  1. 细微之处:比较两种CSS清除浮动的兼容

    http://www.cnblogs.com/bienfantaisie/archive/2011/05/27/2059597.html 清除浮动是连续浮动元素之后的必备工作,在工作中我做到需要清除浮 ...

  2. linux开机启动服务和chkconfig使用方法(自定义服务路径启动)

    服务概述在linux操作系统下,经常需要创建一些服务,这些服务被做成shell脚本,这些服务需要在系统启动的时候自动启动,关闭的时候自动关闭.将 需要自动启动的脚本/etc/rc.d/init.d目录 ...

  3. 《ASP.NET MVC4 WEB编程》学习笔记------UrlHelper

    HtmlHelper帮助我们生成Html标记代码:UrlHelper帮助我们生成URL链接地址 我们学习一下UrlHelper帮助类,看类名也都知道这个类是用来帮我们生成URL在ASP.NET MVC ...

  4. Binary Tree Right Side View

    Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod ...

  5. iOS 和 Android 中的Alert

    iOS 和 Android中都有alert这种提示框,下面简单介绍下. ios中的alert叫做UIAlertView,共有4种样式,由于在ios7上,自定义alertview不太好用,所以也就这4种 ...

  6. BM算法  Boyer-Moore高质量实现代码详解与算法详解

    Boyer-Moore高质量实现代码详解与算法详解 鉴于我见到对算法本身分析非常透彻的文章以及实现的非常精巧的文章,所以就转载了,本文的贡献在于将两者结合起来,方便大家了解代码实现! 算法详解转自:h ...

  7. codeforces B. Making Sequences is Fun 解题报告

    题目链接:http://codeforces.com/problemset/problem/373/B 题目意思:给出w,m和k,需要找出从m开始,可以有多少个连续的数(m+1,m+2,...)(在添 ...

  8. 【USACO】checker

    一看题目 经典的8皇后问题 不过是皇后数量可变而已 不用想 回溯法. 需要个生成每次可选择序列的函数, 在存储可选择的序列时按照先大后小的顺序排的.这样每次找最小和去掉最小都很方便,只要有个记录数量的 ...

  9. [Android Pro] 监听内容提供者ContentProvider的数据变化

    转载自:http://blog.csdn.net/woshixuye/article/details/8281385 一.提出需求 有A,B,C三个应用,B中的数据需要被共享,所以B中定义了内容提供者 ...

  10. openGL纹理映射参数解析

    GLuinttexture[1]; AUX_RGBImageRec *TextureImage[1]; Status=TRUE; // Set The Status To TRUE glGenText ...