5

We use Gitlab for our project, and we have two long-lived branches: dev and master, similar to the Git Flow. And We're using the "merge commit" method, which will create a merge commit in the master branch.

However, the master branch will always ahead of the dev branch because of those "merge commit".

enter image description here

so, my question is, should I merge those "merge commit" back to the dev branch? And Why?

Charlie
  • 2,141
  • 3
  • 19
  • 35
  • 1
    1) you don't merge a _commit_ in `master` to the `dev` branch, you merge the entire branch, and 2) Yes, you need to do this to keep `dev` updated with the latest changes from `master`. You don't have much of a choice for 2) given that you are using a merge-based workflow. – Tim Biegeleisen Jul 16 '20 at 05:17

2 Answers2

3

Should “merge commit” be merged back into the dev branch?

No, unless you want dev to get changes from master (which could have been modified from other branches, like an hotfix)

If dev is long-lived, you merge it to master, but you don't merge master to dev.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Is your dev branch like the master branch ? If you want to have a branch based on the master, you can use :

$ git checkout -b branchname master

Or if you want to update a branch with the master branch, you can use :

$ git merge branchToUpdate master