首页>Program>source

我的工作流程中有许多短期分支,我希望将它们分开.因此,我计划使用 git config --add merge.ff false .但是,当我执行一次拉(我理解为fetch + merge)时,那么我想要一个快速转发的行为,以避免此处不必要的额外提交.

这是一件好事吗?

最新回答
  • 13天前
    1 #

    注意:Git 2.0(2014年第二季度)将通过提交b814da8引入一个配置 push.ff

    pull.ff::
    

    By default, Git does not create an extra merge commit when merging a commit that is a descendant of the current commit. Instead, the tip of the current branch is fast-forwarded.

      When set to false, this variable tells Git to create an extra merge commit in such a case (equivalent to giving the --no-ff option from the command line).

      When set to only, only such fast-forward merges are allowed (equivalent to giving the --ff-only 选项)。


    初始答案(2012年10月)

    尝试:

    git pull --ff
    

    它应该优先于您的合并配置设置。
    它将通过 --ff git pull命令中基础合并的选项。

    提防 --no-ff 但是,如"了解Git工作流程"中所述

    With enough flags you can force Git to act the way you think it should instead of the way it wants to. But that’s like using a screwdriver like a hammer; it gets the job done, but it’s done poorly, takes longer, and damages the screwdriver.

    Consider how a common Git workflow falls apart.

    Create a branch off Master, 
    do work, 
    and merge it back into Master when you’re done
    

    Most of the time this behaves as you expect because Master changed since you branched. Then one day you merge a feature branch into Master, but Master hasn’t diverged. Instead of creating a merge commit, Git points Master to the latest commit on the feature branch, or “fast forwards.” (Diagram)

    Unfortunately, your feature branch contained checkpoint commits, frequent commits that back up your work but captures the code in an unstable state. Now these commits are indistinguishable from Master’s stable commits. You could easily roll back into a disaster.

    So you add a new rule: “When you merge in your feature branch, use –no-ff 强制执行新的提交。" 这样就完成了工作,然后继续前进。

    有一天,您会发现生产中的关键错误,因此需要跟踪该错误的引入时间.您运行 bisect 但请继续检查检查点提交.您放弃手工调查。

    您将错误缩小到单个文件.您运行 blame 了解过去48小时内的变化.您知道这是不可能的,但是 报告文件在几周内没有被触及。
    blame It turns out 报告首次提交时的更改,而不是合并时的更改 .您的第一个检查点提交是在几周前修改此文件的,但是今天的更改已合并。

    blame 创可贴,破裂的二等分和怪罪之谜都是您使用螺丝刀锤子的症状。

    有关更多信息,请参见:

    no-ff

      "With dvcs/git, is a single commit preferred over multiple, small, thematic commits?"

      "git newbie question - Commit style: Commit all changed files at once or one at a time?"

  • python:多处理GUI模式以应对"无响应"阻止
  • knockout.js:KnockoutJS ObservableArray数据分组