- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有我的 master
分支和我的 verydifferentbranch
它们有相同的祖先......大约 300 次提交前。现在 verydifferentbranch
的功能已经完成,我想把它放在主 branch
下。进行 rebase 会导致每个补丁都有很多 merge 冲突,以至于它本身就是一个大项目来解决所有冲突。
除了强制将 verydifferentbranch
的头部 push master
分支之外,我不知道该怎么做。这样做我会失去我所有的历史,而这不是我真正想做的事情。
我还有哪些其他选择?
最佳答案
听起来你的历史是这样的:
...---o---A---o---...---o---o---B master
\
o---o---...---o---C verydifferentbranch
你说你担心强推会丢失历史verydifferentbranch
至 master
.这样的操作实际上会丢弃 A
之后的所有内容直到 B
.
您可以通过 merge 来保留历史记录,或者只是在废弃的分支尖端放置一个标签并使其保持未 merge 状态。
merge 将允许您保留双方的历史记录:
...---o---A---o---...---o---o---B
\ \
o---o---...---o---C---M master
您执行的 merge 类型将决定为提交 M 创建的内容。正常 merge (使用 recursive
merge 策略)听起来会在您的案例中产生大量冲突。 如果您确实需要 merge 来自 A..B
的更改提交时,除了解决由 merge 或 rebase 所带来的冲突外别无他法。它们出现了。)但是,如果你只想 M
与 C
具有相同的内容(即你想忽略由 A..B
提交表示的更改),然后你可以使用 ours
merge 策略。
git-merge(1)描述了 ours
merge 策略:
This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the recursive merge strategy.
您可以使用 Merge commit 'abandoned/foo-features'
的消息生成 M像这样:
git tag -m 'describe reason for abandonment here...' \
abandoned/foo-features master # tag abandoned branch tip
git checkout verydifferentbranch # checkout dominant branch
git branch -M verydifferentbranch master # replace master
git merge -s ours abandoned/foo-features # merge only other's history
git tag -d abandoned/foo-features # optional: delete the tag
git push wherever master tag abandoned/foo-features # publish them
这些命令的变体将为您提供略有不同的 M
自动提交消息(您始终可以提供自己的 git merge -m
或之后用 git commit --amend
进行修改)。
Gist 是生成的 master
将有两条历史记录,但与原始 master
没有任何变化侧(这些更改仍在历史记录中,它们只是未在提交 M
引用的树中表示)。
如果“重写”是可以接受的master
(即没有基于任何提交的其他工作 A..B
,或者所涉及的用户不介意它将对 recover from the rewrite 进行的工作),那么您可以在 master
的当前提示处留下一个标签。并替换 master
与 verydifferentbranch
.
...---o---A---o---...---o---o---B (tag: abandoned/foo-features)
\
o---o---...---o---C master
这样安排:
git tag -m 'describe reason for abandonment here...' \
abandoned/foo-features master # tag abandoned branch tip
git branch -M verydifferentbranch master # replace master
git push wherever +master tag abandoned/foo-features # publish them
关于git - 使用 git merge 两个非常不同的分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5956300/
更新:随意给我反对票,因为问题是我将文件命名为 _stylesheet.html.erb 而不是 _stylesheets.html.erb。我以为我检查了拼写,但显然我没有。我很抱歉浪费了大家的时间
我有一个 Inno Script istaller 在其中运行子 setup.exe 。当向主安装程序提供静默安装参数时,我必须向 setup.exe 提供静默安装参数。 Inno脚本运行命令: [R
我正在尝试在大型数据库中搜索长的、近似的子字符串。例如,一个查询可能是一个 1000 个字符的子字符串,它可能与匹配项相差数百个编辑的 Levenshtein 距离。我听说索引 q-gram 可以做到
我正在尝试在我的应用程序中实现一个非常简单的绘图 View 。这只是我的应用程序的一小部分,但它正在变成一个真正的麻烦。这是我到目前为止所拥有的,但它现在显示的只是莫尔斯电码,如点和线。 - (v
我有一个运行非常慢的 sql 查询,我很困惑为什么。查询是: SELECT DISTINCT(c.ID),c.* FROM `content` c LEFT JOIN `content_meta`
我搜索过这个,但我发现的所有结果对我来说都毫无意义,而且似乎太复杂了。我希望使用 json 或 simplejson 模块来获取对象中字符串的值。 string = '{"name": "Alex"}
我想编写一个流量生成器来复制正在运行的计算机对内存进行的原始读写需求。 但是正在运行的计算机在其内存引用中也显示出(非常强的)局部性,并且在 64 位地址空间中,只会引用非常小范围的地址(事实上,我已
我正在尝试做一个 Project Euler问题,但它涉及添加一个非常大的数字的数字。 (100!) 用Java的int和long太小了。 谢谢你的建议 最佳答案 类 BigInteger看起来它可能
我想在游戏中实现一个物理引擎,以便计算物体在受力时的轨迹。该引擎将根据对象的先前状态计算对象的每个状态。当然,这意味着要在两个时间单位之间进行大量计算才能足够精确。 为了正确地做到这一点,我首先想知道
Edit3:通过将数组的初始化限制为仅奇数进行优化。谢谢@Ronnie! Edit2:谢谢大家,看来我也无能为力了。 编辑:我知道 Python 和 Haskell 是用其他语言实现的,并且或多或少地
背景 我有一个我编写的简单媒体客户端/服务器,我想生成一个非显而易见的时间值,我随每个命令从客户端发送到服务器。时间戳将包含相当多的数据(纳秒分辨率,即使由于现代操作系统中定时器采样的限制,它并不真正
一位招聘软件工程师的 friend 希望我为他开发一个应用。 他希望能够根据技能搜索候选人的简历。 正如您想象的那样,可能有数百、可能数千种技能。 在表格中表示候选人的最佳方式是什么?我在想 skil
我的意思是“慢”,回调类型等待远程服务器超时以有效触发(调用 vimeo 提要,解析它,然后在场景中显示 uiviews) 我大多不明白它是如何工作的。我希望在返回响应后立即从回调中填充我的 View
您好,我正在研究使用快速可靠的生产者消费者队列进行线程切换。我正在使用 VC++ 在 Windows 上工作。 我的设计基于 Anthony Williams队列,基本上就是一个带有 boost::c
我只是想知道您使用 resharper 的经验。我们有一个非常重的 dbml 文件,因为我们的数据库有很多表,每次我需要打开该文件时,我都会收到来自 resharper 的大量异常。以前有人遇到过这个
我目前正在使用 jQuery 中的隐藏/显示功能来帮助从选择框中将表格过滤成组。 实际代码运行良好,但速度非常慢,有时需要一两分钟才能执行。 我切换了代码,所以它使用 css({'display':'
我按顺序调用了以下两个方法(按顺序使用适当的类级别字段) public const string ProcessName = "This is" public const string WindowT
我很难理解描述反射包的文档/示例。我是一名命令式编程老手,但也是一名 Haskell 新手。你能引导我完成一个非常简单的介绍吗? 包裹:https://hackage.haskell.org/pack
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我正在尝试编写一段代码来操作一个很长的文档(超过一百万行)。在这个文本文件中,有固定间隔(每 1003 行)和之间的某些时间戳有我需要的数据,它有 1000 行长,还有一个标题和两个空行,但我不需要。
我是一名优秀的程序员,十分优秀!