Reputation: 799
I encounter a very weird problem in Git (version 2.10.1 (Apple Git-78)).
It seems that if I once set merge.ff
to false
in the local repo config, there is no way back for this repo. I just cannot unset it.
Here are the steps to reproduce:
git init
# Set merge.ff
git config --add merge.ff false
# Add some content and commit.
echo '.' >> file.txt
git add file.txt
git commit -am "commit"
# Create a new branch.
git branch feature
git checkout feature
echo '.' >> file.txt
git commit -am "commit"
git checkout master
git merge feature
This merge creates a commit with message - as expected.
Now I unset the setting, and I expect that future fast-forward commits will create no extra commits. But surprisingly, that does not work.
git config --unset-all merge.ff
git checkout feature
echo '.' >> file.txt
git commit -am "commit"
git checkout master
git merge feature
I'd assume this merge should not create a commit, because there is no merge.ff
setting, so the default should apply. But the commit gets created.
What I want: Having fast-forward commits working again in my repo. Is there a way to get this?
Upvotes: 1
Views: 158
Reputation: 488453
I'd assume this merge should not create a commit, because there is no merge.ff setting, so the default should apply. But the commit gets created.
The default is to fast-forward if possible, otherwise to make a merge commit.
A merge commit is necessary now, because the graph looks like this:
* 4667bf7 (feature) commit
| * 6663675 (HEAD -> master) Merge branch 'feature'
| |\
| |/
|/|
* | c12b7b3 commit
|/
* 3c62604 commit
The merge base of master
and feature
is commit c12b7b3...
:
$ git merge-base master feature
c12b7b3f68caf419c3088fae293c57cfed147f34
and the tip of feature
is 4667bf7
, with the tip of master
being 6663675
. Neither of these two tips is equal to the merge base, so a merge is required.
Your configuration is OK:
$ git config --get merge.ff
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[merge]
(It's rather obnoxious, but harmless, that git config
leaves a bogus empty [merge]
section in there; every additional git config merge.<whatever>
adds another one when there's an empty one.)
Upvotes: 2