git-merge不尊重合并

时间:2015-10-19 15:40:07

标签: git git-merge

我正在尝试配置我的本地git,以便在合并到develop分支时始终使用--squash。正如许多建议所示,我尝试git config branch.develop.mergeoptions "–-squash",但似乎没有效果:

> git checkout -b test_branch
> touch 1 2
> git add 1
> git commit -m "Added 1"
> git add 2
> git commit -m "Added 2"
> git checkout develop
> git merge test_branch
Updating e258d21..90a41ec
Fast-forward
 1 | 0
 2 | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 1
 create mode 100644 2

我的期望是git merge test_branch的结果与git merge --squash test_branch的结果完全相同。但显然不是这样:合并来自test branch的两次提交而不试图压缩它们。

我错过了什么?

本地配置的转储看起来像这样

$ git config --local --list
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git@yyy.com:repo/repo.git
gitflow.branch.master=master
gitflow.branch.develop=develop
gitflow.prefix.feature=feature/
gitflow.prefix.release=release/
gitflow.prefix.hotfix=hotfix/
gitflow.prefix.support=support/
gitflow.prefix.versiontag=
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.develop.remote=origin
branch.develop.merge=refs/heads/develop
branch.develop.rebase=true
branch.develop.mergeoptions=--ff-only –-squash
user.name=User Name
user.email=xxx@yyy.com
log.mailmap=true
push.default=simple

1 个答案:

答案 0 :(得分:1)

你可能在git config中传递选项时输错了。试试这个:git config branch.develop.mergeoptions "--squash"它有用吗?