Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EGit : How to prevent fast-forward merge?

The company I work for gave me the project of moving their java project from CVS to Git. For several reasons, they don't want to use another tool than Eclipse. So we're stuck with EGit.

I searched a lot to find a workflow adapted to our project. This one seemed quite relevant and used by many people : http://nvie.com/posts/a-successful-git-branching-model/

The problem is that when we tried to see how it could work with EGit using commits, branches & merges, a lot of fast-forward merge happened. The problem with fast-forward merges is that it makes you loose the starting point of the branch.

The client we work for wants to be able to choose which features will be in the next release and which will not be. That is one of the main reasons we want to move from CVS to Git, because there seemed to be no easy way in CVS to find which files were modified due to feature #1 and which files were modified for feature #2. In git, we can make branches for feature #1 & #2 and find which files were modified for these features. But, due to fast-forward, it is like going back to CVS, we are not able to know which is feature#1 and which is feature #2.

So is there any way to prevent fast foward merge ? We tried to put these configurations in Eclipse :

[core]
mergeoptions = --no-ff

[merge]
ff = false

But it did not prevent EGit from doing fast-forward merge. If this feature is not implemented with JGit/EGit, would there be any other way to have a workflow using Egit that follows what the client want (ability to choose features for release). Using the command line would probably solve the problem, but if it is possible to keep it in Eclipse, that would be nice.

Thank you

like image 850
Cyril Avatar asked Jul 24 '12 10:07

Cyril


3 Answers

EGit bug 336933 was about supporting these options, and it was fixed with EGit 2.3, see release notes.

If you don't use 2.3 yet, a (ugly) workaround could look like this:

  • Before merging, check if it would result in a fast-forward merge using the History View
  • If it would, make a commit in master (or the branch where you would like to merge into) in an unrelated file
  • Then do the merge
like image 191
robinst Avatar answered Sep 25 '22 17:09

robinst


Note that with the release of Egit 2.3, Egit now supports that option:

Support git merge --no-ff as an EGit preference.

That completes bug 335091.

like image 31
VonC Avatar answered Sep 22 '22 17:09

VonC


It looks like it's not possible, as JGit doesn't support some merge options, including --no-ff.

See this post, there's a bug report on this.

like image 35
CharlesB Avatar answered Sep 23 '22 17:09

CharlesB