玩转GIT之终结git-flow中分支冲突系列问题

图解git flow开发流程 在实际生产开发的过程中,如果每个人都随意的创建分支,随意的提交commit,必将导致整个git仓库非常的混乱,不易于团队协作。Vincent Driessen 同学为了解决这个问题提出了A Successful Git Branching Model,最后形成了业内普遍采用的git 工作流程,大家都在约定的流程内使用git,使得团队协作效率大大提高‌ 下面是git flow的工作流程图: Git Flow 的常用分支 生产分支(master)‌ Master分支是仓库的主分支,这个分支包含最近发布到生 阅读详情
第一种处理方法

开发要求:
不能丢弃本地修改,因为其中的某些内容的确是我们需要的,此时需要对unmerged的文件进行手动修改,删掉其中冲突的部分。


情景再现:
比如你在A分支上commit了,然后PR了,这时你的PR没有冲突的提示,可以合并。但是之后有人在你PR的目标上的相同位置做了修改,这个时候,你的PR就有冲突的提示了,不可以合并,怎么办?

解决方法:
需要先获取远程最新的origin/master分支的上的commitID,然后存在本地mstaer分支上的一个文件内,然后再用git merge origin/master 合并到本地的文件上。然后会出现冲突,再在冲突的文件内根据需求将一些内容删除掉,然后执行git add && git commit && git push origin 就不会再冲突了。

具体代码如下:

// 切换到`branchA`分支
git checkout branchA 
// 获取最新commitID
git fetch origin
// 合并到本地文件上
git merge origin/master
// 对冲突内容进行修改后,执行
git add .
git commint -m 'finished'
git push origin master branchA

下面是官方的一个例子,我写了注释

// 官方例子
// 第一步
git remote add upstream https://github.com/schacon/blink
// 第二步
git fetch upstream

// 输出信息
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
Unpacking objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
From https://github.com/schacon/blink
 * [new branch]      master     -> upstream/master

// 第三步
git merge upstream/master

// 输出信息
Auto-merging blink.ino
CONFLICT (content): Merge conflict in blink.ino
Automatic merge failed; fix conflicts and then commit the result.

// 第四步
vim blink.ino
// 第五步
git add blink.ino
// 第六步
git commit

// 输出信息
[slow-blink 3c8d735] Merge remote-tracking branch 'upstream/master' \
    into slower-blink

// 第七步
git push origin slow-blink

// 输出信息
Counting objects: 6, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 682 bytes | 0 bytes/s, done.
Total 6 (delta 2), reused 0 (delta 0)
To https://github.com/tonychacon/blink
   ef4725c..3c8d735  slower-blink -> slow-blink
第二种解决方法

如果我们确定远程的分支正好是我们需要的,而本地的分支上的修改比较陈旧或者不正确,那么可以直接丢弃本地分支内容,运行如下命令(看需要决定是否需要运行git fetch取得远程分支):

$:git reset --hard origin/master
Git Flow Git Flow 是一种基于 Git 的分支模型,旨在帮助团队更好地管理和发布软件。Git Flow 由 Vincent Driessen 在 2010 年提出,并通过一套标准的分支命名和工作流程,使开发、测试和发布过程更加有序和高效。 阅读详情

相关推荐

git的分支管理策略

stable-版本号。

ckh20040422的博客 792

Git 高级技巧:从分支管理到冲突解决

在日常开发中,Git 已经成为开发者不可或缺的工具。虽然大多数人已经熟悉了commit、push和pull等基础命令,但 Git 的功能远不止于此。本文将带你深入探索 Git 的高级工作流,帮助你更高效地管理项目,解决复杂问题,并提升团队协作效率。

呱牛 Just do IT 579

Git 分支管理策略对比:Git Flow vs GitHub Flow vs GitLab Flow 的 5 个核心差异

本文深度对比了Git Flow、GitHub Flow和GitLab Flow三种主流分支管理策略的5个核心差异,包括长期分支结构、功能开发流程、发布模式、团队规模适配性和CI/CD集成复杂度。通过详细分析各策略的优缺点及适用场景,为开发者提供多人协作环境下的最佳分支管理实践指南,帮助团队提升开发效率和代码质量。

civtsbiqr522632413的博客 441

Git多个远程仓库不同步时的补救办法

当git remote关联了多个远程仓库时,总会遇到一些问题。今天就遇到了两个远程仓库不一致导致无法push的情况。

前端原创分享,常年坚持记录和分享,全网阅读量超百万 931

git的使用葵花宝典,模块化开发,git flow,代码冲突的解决,GitLabWeb

git的使用葵花宝典,模块化开发,git flow,代码冲突的解决,GitLabWeb

Avalonia跨平台开发入门:从安装到运行第一个应用(Windows/Linux/macOS)

本文详细介绍了Avalonia跨平台开发的基础入门指南,从安装到运行第一个应用的全过程。涵盖Windows、Linux和macOS三大平台的环境配置,特别推荐使用Visual Studio进行开发,并提供常见问题的解决方案,帮助开发者快速上手Avalonia框架。

weixin_28688385的博客 542

git flow feature特性减少冲突的逻辑处理

用git flow 合并冲突之前要做以下事情: 1,每次的hotfix修复合并之后,都要通知全员,将feature与develop进行合并,同时处理冲突;这是必须的,避免积攒的特别多时造成耗时非常久; 2,大家每天来公司的第一件事就是git pull的方式,将代码同步下feature,将别人提交的代码都合并到自己的本地,有冲突的话,及时合并处理。这样避免积攒冲突; 3,每天晚上编码结束后,都要进行一些与develop合并,保持代码更新;避免积攒冲突;合并完成之后,再提交自己的特性代码; 4,统一使用

王森的博客 545

再生龙(clonezilla)镜像比目标盘大——基于centos8.5

再生龙恢复到小盘遇到的问题及处理,首先是修改分区大小,进入dracut模式后再尝试恢复临时系统。

u010101453的博客 3689

Git Flow开发流程;创建分支与合并分支;解决冲突

Git Flow开发流程举例 项目背景: 有一群人共同开发一个博客网站。 项目人员: 开发人员: a、b 开发 leader:c 测试人员: d 部署人员:e 项目分工: a 负责 articles 文章模块,b 负责 login 登录模块 c 负责审核和合并 a 和 b 开发的模块代码(代码 review 和合并代码到 develop 和 master 分支) d 需要等模块开发完毕后...

Bule_daze的博客 1890

开源LocalAI本地人工智能安装教程

LocalAI是一款能在本地运行的人工智能应用,它兼容了OpenAI API规范,它可以在普通的电脑运行,不需要GPU,也不需要联网,音频转录

2301_78652552的博客 3613

量化实战:如何用Barra多因子模型给你的投资组合做一次‘风险体检’?

本文详细介绍了如何利用Barra多因子模型对投资组合进行全面的风险体检,帮助投资者识别行业和风格因子的风险暴露。通过实战案例和Python代码示例,展示了数据采集、风险归因和组合优化的完整流程,提升投资组合的风险调整收益。

weixin_27215337的博客 323

企业级 Git 分支管理模型实战:从 Git Flow 到 DevOps 落地

在小型团队或个人开发中,简单的分支操作或许能满足需求,但进入企业级项目后,多环境部署、多团队协作、高频迭代等场景,必然需要一套标准化的 Git 分支管理模型。一套优秀的分支模型,能解决 “代码冲突频发”“环境不一致”“上线回滚困难” 等核心痛点,让开发、测试、运维流程高效协同。本文结合企业级开发模型的核心内容,详解主流的 Git Flow 分支规范、环境与分支的对应关系,以及从需求开发到紧急修复的完整落地流程,帮你搭建适配企业场景的 Git 协作体系。

会当凌绝顶,一览众山小 3275

RK3588平台MIPI DSI屏幕调试记录

本文是基于RK3588平台,MIPI屏调试总结。调试过程中遇到的问题:一开始很久没亮,测量了电源电压和波形都正常。后来换了一组板子和屏幕做对比。最后是因为屏幕的座子没焊接好,二是接MIPI屏幕的排线太长会影响数据传输。换了一根短的线之后屏幕亮起。vp2vp3。

bingdund的博客 1389

git分支详解

git分支 git有一个中心仓库,库中有一个产品A的设计图纸,这个就是master。

weixin_43660088的博客 2万+

17、自适应和学习索引:在线物理设计调整的新维度

本文探讨了现代数据库管理系统中自适应索引和数据库裂解的新方法,通过结合学习模型与多臂老虎机(MAB)框架,实现在线物理设计调整。文章详细介绍了自适应索引的工作原理、数据库裂解技术以及如何利用机器学习进行索引选择和优化,并讨论了MAB框架在动态调整索引结构中的应用及其实际案例。

go5gopher的博客 81

Android NDK/JNI面试题大全及参考答案(3万字长文)

是一套工具集合,它允许开发者为Android平台编写原生应用程序或者应用程序的部分模块。NDK 主要用于开发那些需要高性能计算的应用程序,例如游戏引擎、图像处理软件或音频/视频编码解码器等。通过使用 C 或 C++ 编写代码,开发者可以利用硬件加速功能,提高应用性能。NDK 提供了一系列工具来帮助开发者完成从源代码到可执行文件的整个过程,包括编译、链接、调试等功能。

大模型大数据攻城狮的专栏 1257

【Git】第十七节:Git 分支策略(Git Flow)—— 主流分支模型与标准化版本发布流程

Git Flow是一种标准化的Git分支管理策略,适用于需要规范版本发布的软件项目。它定义了五类核心分支:main(生产代码)、develop(开发主线)、feature/(功能开发)、release/(发布准备)和hotfix/*(紧急修复)。每种分支都有明确的创建、合并规则和生命周期。Git Flow通过feature分支开发新功能,release分支准备正式版本,hotfix分支处理线上问题,最终代码会合并到main和develop分支。

silverclayz的技术分享 3569

DLMS/COSEM协议的理解体会

DLMS是通信协议,COSEM是电表建模规范。HDLC帧基本格式为0x7e......

一个bug是bug,多个bug能work 8312

git分支branch详解

上一篇git的基本原理http://blog.youkuaiyun.com/xiaoputao0903/article/details/23912561,介绍了git最基本的原理和相关操作,这篇就来讲讲git的分支。 1.git的分支是什么         顾名思义,分支就是从主线上分离出来进行另外的操作,而又不影响主线,主线又可以继续干它的事,是不是有点像线程,最后分支做完事后合并到主线上而分支的任务完

雨中奔跑 2万+

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Git Flow分支模型

✅ Git 合并靠的是三方合并:找共同祖先 + 比较两边 diff 合并内容,而不是简单看提交指针或谁快谁慢!“哦你只是继续往 feat1 分支上加了一个提交,那我只需要合并 C3 的 diff 就行。那合并时,就会冲突,因为从共同祖先 B 开始,两边都对这行做了不同的修改。预发布分支(release/*)用于测试,测试完成合并到 main。适合快速迭代和持续部署的项目,只有一个主分支(main。用于日常开发,合并功能分支(feature/*);✅ 合并时不会乱套,也不会重复合并旧的提交。

JacinLee的博客 930

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Git-flow分支管理与Aone-flow分支管理对比

比如上线后的 Hotfix,正常的处理方法应该是,创建一条新的发布分支,对应线上环境(相当于 Hotfix 分支),同时为这个分支创建临时流水线,以保障必要的发布前检查和冒烟测试能够自动执行。但其实还有一种简便方法是,将线上正式环境对应的发布分支上关联的特性分支全部清退掉,在这个发布分支上直接进行修改,改完利用现成的流水线自动发布。每当开始一件新的工作项(比如新的功能或是待解决的问题)的时候,从代表最新已发布版本的主干上创建一个通常以feature/前缀命名的特性分支,然后在这个分支上提交代码修改。

IT枫斗者的博客 2177

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Git Flow / Git分支模型

修复错误后,可以将该分支与主分支合并,并打上一个标签。它与主分支平行存在,也被视为项目的主要分支。如果你编辑了一个团队项目的主分支,你的更改将影响其他所有人,并且很快就会出现合并冲突。在这个分支上,开发人员可以进行小的缺陷修复和准备发布的元数据。发布分支将包含预定数量的特性分支。当开发分支达到稳定点并准备发布时,应将其与主分支合并,并打上发布版本的标签。这个分支模型中的两个分支被视为项目的主要分支。你的本地仓库有一个与远程仓库的主分支始终保持更新的主分支。修复分支与发布分支类似,都是用于新的生产发布。

m0_65696193的博客 879

Git分支branch详解

上一篇git的基本原理介绍了git最基本的原理和相关操作,这篇就来讲讲git的分支。 1.git的分支是什么 顾名思义,分支就是从主线上分离出来进行另外的操作,而又不影响主线,主线又可以继续干它的事,是不是有点像线程,最后分支做完事后合并到主线上而分支的任务完成可以删掉了。这样是不是很方便,主线继续做它的事,分支用来解决临时需求,二者互不相干。 git...

专注自动化、性能测试、测试架构学习交流 3万+

功能分支管理:git flow feature命令深度解析

本文深入解析Git Flow工作流中功能分支管理的完整生命周期,涵盖功能分支的创建与命名规范、开发过程的生命周期管理、分支发布与跟踪机制,以及功能完成时的合并策略与冲突解决方案。通过详细的命令示例、流程图和最佳实践,帮助团队建立高效、规范的代码管理流程。 ## 功能分支的创建与命名规范 在Git Flow工作流中,功能分支(Feature Branch)是开发新功能的核心载体,合理的创建和命...

gitblog_00929的博客 1001

Git 分支管理

Git 分支管理

layneyao的博客 1349
上一篇: 玩转GIT之git-flow中容易忘记的git命令
下一篇: 子网掩码最简单通俗的解释
杨不败
博客等级 码龄10年 46粉丝 87原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值