git 如何不显示 merge branch xx into xx 的记录

199 天前
 yujianwjj

remote 的 develop 分支,经过 merege request 之后,commit: xx 历史记录里面会有两条,一条是本身的 commit 记录,还有一条是 merge branch feature_x into deveop 的记录。

如何去掉 merge branch feature_x into deveop 这个 commit 记录?

2641 次点击
所在节点    git
27 条回复
virusdefender
199 天前
用 rebase ,gitlab 之类的都有选项可以调
vincent20
199 天前
rebase
virusdefender
199 天前
gitlab 的选项

Merge method
Determine what happens to the commit history when you merge a merge request. How do they differ?

Merge commit
Every merge creates a merge commit.

Merge commit with semi-linear history
Every merge creates a merge commit.
Merging is only allowed when the source branch is up-to-date with its target.
When semi-linear merge is not possible, the user is given the option to rebase.

Fast-forward merge
No merge commits are created.
Fast-forward merges only.
When there is a merge conflict, the user is given the option to rebase.
MENGKE
199 天前
git merge xxx --no-ff
MENGKE
199 天前
@MENGKE 不好意思看错问题了
Plutooo
199 天前
rebase + 1
hokori
199 天前
rebase
0x2CA
199 天前
对于 git 的操作应该是 merge 而不是 rebase ,对于任何的操作应该都需要记录,如果你使用 rebase ,实际上你操作了,提交的 commit 不一定是你要提交的,想退回会比较困难,如果你不想要看见这样的记录,可以自定义 commit 信息,但是一定要有这个 commit
wu67
199 天前
git log --no-merges
victimsss
199 天前
虽然平常都是 rebase ,然而我更喜欢 merge 的做法。
zxf4399
199 天前
git merge --ff-only <branch>
pkoukk
199 天前
多人协作的时候,这条 merge 记录是有意义的,它代表由谁审核过了这个 merge ,并允许合并的
例如,开发这个项目的有 2 个 maintainer A ,B ,功能由 developer C 开发
那合并记录就能看出来,功能的 commit 是 C 做的,如果 merge commit 是 A ,说明是 A review 之后合进来的
shawndev
199 天前
--ff-only
superchijinpeng
199 天前
fast forward
adoni
199 天前
在本地使用 rebase
在远端(网页上 merge 的时候)使用 fastforward
adoni
199 天前
@0x2CA 这个还是看不同的开发模式,主干开发不一定需要这样
unco020511
199 天前
sycwiki
199 天前
rebase/cherry-pick
nothingistrue
199 天前
merge branch xx into xx 是一条正式 Git 提交,你要是去了,你会被打死,谨记。
nothingistrue
199 天前
如果你不想让出现 merge branch feature_x into deveop 的提交,那么你需要调整的是修改 merege request 的执行合并的方式,让起实质上只能是压缩提交,或者快速合并。但之前已经做过的,是不能改的。

压缩提交方式,会将待合并分支的所有提交先压缩成一个提交,一般不建议这么做,严重丢失历史。

快速合并有前提的,两个分支开叉的地方,必须是主分支的 Head ,即实际上主分支原地没动,只有待合并分支生成了新内容。要么你需要外部限定一次只能有一个开发分支(这就不存在分布式开发了,实际上连 SVN 都不算,直接回到了 VSS 时代的先锁定后修改方式)。要么得借助于然 rebase ,待合并分支先变基,然后再往主分支合并(这就类似于 SVN 方式了)。并且,你还得配置 merege request 的执行方式是 --ff-only 。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/984385

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX