1

Following situation. I work on feature branches in git which I merge into common develop branch when I'm finished with the corresponding feature. Since it can take considerable time to get a feature completed, I merge the develop into my feature branch on a regular basis, to keep getting updates of code by my colleagues.

Now, when I'm finished and merge my feature branch into develop, all commits I've done on the feature branch appear in the history of develop. But I would like to have only one merge commit to keep the history clear. I don't need all the intermediate stuff.

Is that possible?

Ewgenij Sokolovski
  • 897
  • 1
  • 12
  • 31

1 Answers1

1

Here is what you do in such situation

  1. Checkout your feature branch
  2. Run git rebase develop
  3. Checkout your develop branch
  4. Run git merge feature

Done

e.doroskevic
  • 2,129
  • 18
  • 25
  • Hmm, I think I tried it out couple of days ago and had the same problems of the whole history getting over. But I will try again with the next feature branch. – Ewgenij Sokolovski Jul 22 '16 at 12:42
  • Let me know how you get on and I will help you out if I can – e.doroskevic Jul 22 '16 at 12:49
  • Thanks. Hmm, maybe there is something wrong with my setup? I merged my feature branch into develop just now, without doing any merge from develop to feature before! It was a short feature. But nevertheless I got all my intermediate commits in the feature branch into my develop. Why??? – Ewgenij Sokolovski Jul 27 '16 at 09:30
  • If you haven't had any updates on your develop branch prior to merge of your feature branch, it would mean your feature branch was up to date with your develop branch and therefore could carry out fast-forward merge – e.doroskevic Jul 27 '16 at 09:35
  • I am rather confused then how could this be achieved without being exposed to a merge conflict where you'd need to update your local repo prior to merge. Perhaps someone else may be able to pinch in on this one – e.doroskevic Jul 27 '16 at 13:38