I am still new to this so I am trying to understand why master
ends up 1 commit ahead of develop
instead of the same after merging a release
branch back into develop
and master
.
My develop
branch was 5 commits ahead of master, then I created a release
branch and tagged which was also 5 commits ahead of master
, then I merged release
branch back into develop
and master
but master
ends up 1 commit ahead of develop
.
Is this because no changes were made to the release
branch and it was the same as develop
so the merge didn't create a commit on develop
but it did on master
which makes master
1 commit ahead even though master
and develop
now are the same at this point?
Is this ok? Will this cause any problems?
Merging your branch into master is the most common way to do this. Git creates a new commit (M) that is referred to as a merge commit that results from combining the changes from your feature branch and master from the point where the two branches diverged.
A branch can be both ahead and behind at the same time if you have made changes to your branch, and someone else have made changes on the default branch that you have not merged into your branch yet. I have a branch with 6 commits, and it shows 4 commits behind master in Bitbucket Cloud.
When you perform a merge, you effectively merge one branch into another—typically a feature branch or bug fix branch into a main branch such as master or develop. Not only will the code changes get merged in, but also all the commits that went into the feature branch.
If the merge request is approved without conflict, the GitLab master will merge into the branch, and both the master and release branches will be in sync. The source code and sample project used for these examples can be found on the gitlab-made-easy project page on GitLab.
The issue is that the merge commit is being detected. Your commit history probably looks something like this:
*------------------ A [master]
\ /
*---*---*---*---B [develop,release]
Commit B
is, as you mention, 5 commits ahead of master
. When you merged the release branch back into master
, this created a merge commit, A
. That merge commit does not yet exist in develop
.
This is not something that you need to worry about, because the merge commit doesn't contain any changes itself, it only merges the two histories together. Normally, that commit will automatically end up in develop
next time you finish a hotfix
branch anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With