quaylar
quaylar

Reputation: 2635

Merge/rebase workflow

I am in the process of changing my git-merge-workflow and encountered following problem:

Up to now, i have been merging (--no-ff) my changes on the develop branch back to master whenever i released a new version. This generated a new merge-commit containing the history (--log) of all the develop-commits. I realized that this is sub-optimal, and want to actually do fast-forward merges from my develop branch to master (having changed my commit-messages on develop to reflect my changes in a "cleaner" way).

My current problem: The most recent commit on master is a still a merge-commit from the last time, due to that I can't do an ff-merge from develop to master now, since the 2 branches "diverged" (the merge-commit is missing on develop).

My idea to solve this would have been, being on develop: git rebase master, which would pull in this merge-commit, and then enable me to do a git merge develop on master. But would this generate a new commit on develop (this particular merge-commit) or will git be smart enough to recognize that the changes of this merge-commit are already part of develop?

Upvotes: 1

Views: 224

Answers (2)

gtr32x
gtr32x

Reputation: 2063

Your method should allow it to work. Another way you can tackle this of course is to remove your develop branch completely at the next merge to master in case rebasing failed. Then just branch off a new develop from master and rebase from that point onwards.

At my previous company we tried to switch our workflow from merging to rebasing as well. But it ended up having all sorts of weird issues from merging of different branches. It just felt cleaner and safer to start anew on the develop branch directly from master.

Upvotes: 0

Amber
Amber

Reputation: 526483

git rebase master while on develop will work fine for your purposes.

If your branches are currently like this:

A-B-C-D-E <-- master
       /
  F-G-H-I-J <-- develop

then they'll wind up like this (because I-J is the only bit not reachable from E):

A-B-C-D-E <-- master
         \
          I'-J' <-- develop

which will then fast-forward merge back into master like this:

A-B-C-D-E-I'-J' <-- master

Upvotes: 1

Related Questions