It is very typical for Git newcomers to inadvertently create merges and worst: inadvertently pushing them. This is one of the reasons many experienced users prefer to avoid 'git pull', and recommend newcomers to avoid it as well.
To avoid these problems and keep 'git pull' useful, it has been agreed that 'git pull' should barf by default if the merge is non-fast-forward. Unfortunately this breaks backwards-compatibility, so we need to be careful about the error messages we give, and that we provide enough information to our users to move forward without distrupting their workflow too much. With the proper error messages and documentation, it has been agreed that the new behavior is OK. These are the steps needed to achieve this: 4) Only allow fast-forward merges by default We could pass --ff-only to `git merge`, however, if we do that we'll get an error like this: Not possible to fast-forward, aborting. This is not friendly; we want an error that is user-friendly: The pull was not fast-forward, please either merge or rebase. If unsure, run 'git pull --merge'. When we do this we want to give the users the option to go back to the previous behavior, so a new configuration is needed. 3) Add merge-ff-only config This option would trigger a check inside `git pull` itself, and error out with the aforementioned message if it's not possible to do a fast-forward merge. However, this option conflicts with --rebase, and --no-rebase. Solution below. 2) Add --merge option Since we have a message that says "If unsure, run 'git pull --merge'", which is more friendly than 'git pull --no-rebase', we should add this option, and deprecate --no-rebase. However, the documentation would become confusing if --merge is configured in pull.rebase, instead, we want something like this: See `pull.mode`, `branch.<name>.pullmode` in linkgit:git-config if you want to make `git pull` always use `--merge`. 1) Rename pull.rename to pull.mode and branch.<name>.rebase to branch.<name>.pullmode This way the configurations and options remain consistent: git pull --merge pull.mode = merge branch.<name>.pullmode = merge git pull --rebase pull.mode = rebase branch.<name>.pullmode = rebase git pull --rebase=preserve pull.mode = rebase-preserve branch.<name>.pullmode = rebase-preserve git pull pull.mode = merge-ff-only branch.<name>.pullmode = merge-ff-only This patch series does all the steps mentioned, but in reverse order, and in addition updates the tests to use the new configurations instead. Felipe Contreras (6): pull: rename pull.rename to pull.mode pull: migrate all the tests to pull.mode pull: refactor $rebase variable into $mode pull: add --merge option pull: add merge-ff-only option pull: only allow ff merges by default Documentation/config.txt | 37 ++++++++------- Documentation/git-pull.txt | 28 ++++++++++-- branch.c | 4 +- builtin/remote.c | 14 +++++- git-pull.sh | 105 ++++++++++++++++++++++++++++++++----------- t/t3200-branch.sh | 40 ++++++++--------- t/t4013-diff-various.sh | 2 +- t/t5500-fetch-pack.sh | 2 +- t/t5505-remote.sh | 2 +- t/t5520-pull.sh | 90 ++++++++++++++++++++++++------------- t/t5524-pull-msg.sh | 2 +- t/t5601-clone.sh | 4 +- t/t5700-clone-reference.sh | 4 +- t/t6022-merge-rename.sh | 20 ++++----- t/t6026-merge-attr.sh | 2 +- t/t6029-merge-subtree.sh | 6 +-- t/t6037-merge-ours-theirs.sh | 10 ++--- 17 files changed, 245 insertions(+), 127 deletions(-) -- 1.9.2+fc1.3.gade8541 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html