Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent merge from falling back to normal merge strategy when a fast-forward merge is not possible?

The git merge command has an option to perform fast-forward merge, but this is not what I want, because if it can't do a fast-forward merge, it uses the normal merge.

Is there a git command which only performs a fast-forward merge (from the tracked remote branch) and does nothing if the fast-forward merge is not possible?

like image 306
Mot Avatar asked May 18 '11 07:05

Mot


People also ask

How do you merge without fast forward?

No Fast-forward Merge Typically, this is when maintaining a definite branch topology. For doing so, the --no-ff parameter can be passed with the git merge command. Resultantly, the git merge command will construct a commit merge rather than fast-forwarding.

Can a fast forward merge ever have merge conflicts?

Note that merge conflicts will only occur in the event of a 3-way merge. It's not possible to have conflicting changes in a fast-forward merge.

What happens fast forward merge?

Fast-forward merges literally move your main branch's tip forward to the end of your feature branch. This keeps all commits created in your feature branch sequential while integrating it neatly back into your main branch.

Is Fast forward merge default?

As stated above, Git's default is to use fast-forward merge. It will take the commits from the branch being merged and place them at the tip of the branch you're merging into. This creates a linear history, which is also the main advantage of using fast-forward merge.


1 Answers

From the git-merge man page:

--ff-only

Refuse to merge and exit with a non-zero status unless the current HEAD is already up-to-date or the merge can be resolved as a fast-forward.

like image 101
Mat Avatar answered Sep 18 '22 00:09

Mat