I have two main branches; Dev and Master. New branches are only created from the Dev branch, and are merged into the Dev branch. Eventually Dev is merged into Master. Branches are never created from Master. Frequently, I get notice that my Dev branch is behind Master by X commits and to sync. How can Dev ever get behind Master, if my dev team never creates branches from Master, or merges into master? I've asked my dev team and confirmed that they do not branch from Master or merge into Master.
Hi @Loris Gifts and welcome to the community!
If the Dev branch is behind Master, this means that there are one or multiple commits on the Master branch that are not reachable by the tip of the Dev branch. The message has nothing to do with the diff between the two branches, it only has to do with commits being reachable.
If commits are not pushed to Master branch directly, this can happen when you merge a PR from Dev to Master with merge commit or squash merge. The merge commit or the squashed commit will be added to Master branch when you merge, but that commit will not be reachable by the tip of Dev branch.
Assume the following commit graph, with A, B, C, and D representing commits. A and B are commits on the Master branch, while C and D are commits on the Dev branch.
C - D <-- Dev branch
/
A - B - <-- Master branch
If you merge Dev into Master with a merge commit, the graph will look as follows:
C - - D <-- Dev branch
/ \
A - B - - - - E <-- Master branch
Master will point to commit E, the merge commit, while Dev branch is still pointing at commit D. Commit E is not reachable by Dev branch, so in this case the Dev branch will be 1 commit behind Master.
I hope this helps, please feel free to reach oout if you have any questions.
Kind regards,
Theodora
Much more complex than I understood. Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Loris.
I encountered the similar issue.
It says that dev branch is 3 commits behind the main branch and I cannot merge.
How can I resolve this issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ted,
There may be branch restrictions on the repo that restrict which users can push to certain branches and/or merge PRs on certain branches. There might also be an enforced merge check "Maximum number of commits behind destination branch", that prevents you from merging.
If you have admin access to the repo, you can check that from Repository settings > Branch restrictions. Otherwise, you'll need to ask a repo admin to check.
If this is not the case, please create a new question in community providing more details (e.g. error messages) and we will look into it. You can create a new community question for Bitbcuket via this link:
https://community.atlassian.com/t5/forums/postpage/board-id/bitbucket-questions
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much, Theodora.
Should repo admin resolve this issue via command line on local, right?
Or is there any other methods in the software engineering standard?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.