How do I make git merge's default be --no-ff --no-commit?

前端 未结 4 1047
一个人的身影
一个人的身影 2020-12-04 07:08

Company policy is to use --no-ff for merge commits. I personally like to adjust merge log messages so I use --no-commit. Plus I like to actually co

相关标签:
4条回答
  • 2020-12-04 07:44

    To make --no-ff --no-commit the default merge behavior, set the options to no using:

    git config --global merge.ff no
    git config --global merge.commit no
    

    However, the problem with this is that git pull = git fetch + git merge. So whenever you pull from the remote server, you'd be creating an ugly merge commit when a simple fast-forward would be warranted. To solve this, set pull.ff to yes:

    git config --global pull.ff yes
    
    0 讨论(0)
  • 2020-12-04 07:46

    Put this in $HOME/.gitconfig:

    [merge]
        ff = no
        commit = no
    

    You can use git-config to do this:

      git config --global merge.commit no
      git config --global merge.ff no
    
    0 讨论(0)
  • 2020-12-04 07:54

    According to manual, you should use

    $ git config [--global] merge.ff false
    

    to set no-fast-forward option by default for all branches with git-config utility.

    0 讨论(0)
  • 2020-12-04 08:06

    As of version 1.7.6 of git, you should use

    git config [--global] merge.ff no
    

    to "force" using --no-ff in every merge.

    Default behaviour is

    git config [--global] merge.ff yes
    

    And with

    git config [--global] merge.ff only
    

    it will refuse non-fast-forward merges

    0 讨论(0)
提交回复
热议问题