V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
yujianwjj
V2EX  ›  git

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

  •  
  •   yujianwjj · 187 天前 · 2616 次点击
    这是一个创建于 187 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    27 条回复    2023-10-23 20:23:40 +08:00
    virusdefender
        1
    virusdefender  
       187 天前
    用 rebase ,gitlab 之类的都有选项可以调
    vincent20
        2
    vincent20  
       187 天前
    rebase
    virusdefender
        3
    virusdefender  
       187 天前
    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
        4
    MENGKE  
       187 天前
    git merge xxx --no-ff
    MENGKE
        5
    MENGKE  
       187 天前
    @MENGKE 不好意思看错问题了
    Plutooo
        6
    Plutooo  
       187 天前
    rebase + 1
    hokori
        7
    hokori  
       187 天前
    rebase
    0x2CA
        8
    0x2CA  
       187 天前
    对于 git 的操作应该是 merge 而不是 rebase ,对于任何的操作应该都需要记录,如果你使用 rebase ,实际上你操作了,提交的 commit 不一定是你要提交的,想退回会比较困难,如果你不想要看见这样的记录,可以自定义 commit 信息,但是一定要有这个 commit
    wu67
        9
    wu67  
       187 天前
    git log --no-merges
    victimsss
        10
    victimsss  
       187 天前
    虽然平常都是 rebase ,然而我更喜欢 merge 的做法。
    zxf4399
        11
    zxf4399  
       187 天前
    git merge --ff-only <branch>
    pkoukk
        12
    pkoukk  
       187 天前
    多人协作的时候,这条 merge 记录是有意义的,它代表由谁审核过了这个 merge ,并允许合并的
    例如,开发这个项目的有 2 个 maintainer A ,B ,功能由 developer C 开发
    那合并记录就能看出来,功能的 commit 是 C 做的,如果 merge commit 是 A ,说明是 A review 之后合进来的
    shawndev
        13
    shawndev  
       187 天前
    --ff-only
    superchijinpeng
        14
    superchijinpeng  
       187 天前 via iPhone
    fast forward
    adoni
        15
    adoni  
       187 天前
    在本地使用 rebase
    在远端(网页上 merge 的时候)使用 fastforward
    adoni
        16
    adoni  
       187 天前
    @0x2CA 这个还是看不同的开发模式,主干开发不一定需要这样
    unco020511
        17
    unco020511  
       187 天前
    sycwiki
        18
    sycwiki  
       187 天前
    rebase/cherry-pick
    nothingistrue
        19
    nothingistrue  
       187 天前
    merge branch xx into xx 是一条正式 Git 提交,你要是去了,你会被打死,谨记。
    nothingistrue
        20
    nothingistrue  
       187 天前
    如果你不想让出现 merge branch feature_x into deveop 的提交,那么你需要调整的是修改 merege request 的执行合并的方式,让起实质上只能是压缩提交,或者快速合并。但之前已经做过的,是不能改的。

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

    快速合并有前提的,两个分支开叉的地方,必须是主分支的 Head ,即实际上主分支原地没动,只有待合并分支生成了新内容。要么你需要外部限定一次只能有一个开发分支(这就不存在分布式开发了,实际上连 SVN 都不算,直接回到了 VSS 时代的先锁定后修改方式)。要么得借助于然 rebase ,待合并分支先变基,然后再往主分支合并(这就类似于 SVN 方式了)。并且,你还得配置 merege request 的执行方式是 --ff-only 。
    tusj
        21
    tusj  
       187 天前
    git pull -r
    nothingistrue
        22
    nothingistrue  
       187 天前
    merge branch xx into xx 正好跟外部文档上的 merge request 一一对应,是一条非常有用的提交。安心留着吧。
    ilovey482i
        23
    ilovey482i  
       187 天前
    我很好奇,为啥楼为啥要去掉这个呢?
    lete
        24
    lete  
       187 天前
    @ilovey482i #23 看着难受
    kirory
        25
    kirory  
       187 天前
    grep -v 'merge branch'
    nightwitch
        26
    nightwitch  
       187 天前
    @ilovey482i 管理的不好容易出现 merge hell 。。比如同时有 2-3 个活跃的分支在往主线合并,交叉的连线很容易变成蜘蛛网。 比如这种提交历史基本就没法看了
    duanxianze
        27
    duanxianze  
       187 天前
    根据我的实际经验,不要有这种洁癖,难看总比出问题要好
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1121 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 18:06 · PVG 02:06 · LAX 11:06 · JFK 14:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.