3

I saw a command line reference which recommended git pull --rebase --ff-only. I thought git would reject that, but it doesn’t.

What does the combination of --rebase with --ff-only mean?

Edit: I perfectly know what each alone does.

Robert Siemer
  • 32,405
  • 11
  • 84
  • 94
  • possible duplicate of [Difference between git pull --rebase and git pull --ff-only](http://stackoverflow.com/questions/25430600/difference-between-git-pull-rebase-and-git-pull-ff-only) – Avalanche Jul 21 '15 at 20:36
  • 1
    No, that's not a duplicate. It's the combination of `--rebase` and `--ff-only` passed to `git pull` this is about. – sschuberth Jul 21 '15 at 20:40
  • Maybe the recommendation should be either rebase or --ff-only because the default behavior makes merge commits automatically. – Joseph K. Strauss Jul 21 '15 at 20:51

2 Answers2

4

[Edit, 4 Dec 2016: as of Git version 2.6, git pull is no longer a script, so it is no longer easy to see what it does and the technical details below no longer apply. But --ff-only is still only useful when merging, not when rebasing.]

The git pull script (you can view it yourself, e.g., less $(git --exec-path)/pull) currently separates out --ff-only into a variable named $ff_only that it subsequently ignores entirely if it winds up doing a rebase:

case "$rebase" in
true)
        eval="git-rebase $diffstat $strategy_args $merge_args $rebase_args $verbosity"
        eval="$eval $gpg_sign_args"
        eval="$eval --onto $merge_head ${oldremoteref:-$merge_head}"
        ;;
*)
        eval="git-merge $diffstat $no_commit $verify_signatures $edit $squash $no_ff $ff_only"
        eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
        eval="$eval $gpg_sign_args"
        eval="$eval FETCH_HEAD"
        ;;
esac
eval "exec $eval"

What this means in the end is that your --ff-only option gets ignored.

It's possible that in the future, git might reject these as incompatible, so it's probably wiser to leave out an explicit --ff-only when using an explicit --rebase.

torek
  • 448,244
  • 59
  • 642
  • 775
0

Seems --ff-only will be ignored when using --rebase.

Brett DeWoody
  • 59,771
  • 29
  • 135
  • 184