When creating a merge request in gitlab I often get a message: Request to merge branch-A into develop ([x] commits behind) what does gitlab want to tell me? should I worry or d
If you're seeing a 'behind by X commits' message, gitlab is indicating that the branch you're merging into has moved on from the point where you branched.
When you review the diffs in gitlab, they can seem confusing, possibly suggesting that you're about to undo changes that are implemented in later commits on the target branch.
If you want to be sure you're seeing exactly the changes that the merge will perform, the safest thing to do is to update the branch you want to merge by first merging in the target branch...
# fetch the latest code on all branches
git fetch
# checkout your working branch (if you're not already on it)
git checkout branch-A
# merge in the target branch
git merge origin/develop
Fix any conflicts that may arise, then commit them:
# stage changes & commit
git add .
git commit
# push changes to origin
git push
If you now refresh the merge request page on gitlab, the 'behind' message will disappear and the diffs will reflect the changes you've made only.
This is much safer than rebasing your branch as it does not require a --force
push. It also means that the chronology of the git timeline matches what actually happened, so if you're trying to track down an issue in the future, you won't be mislead by a re-writing of history.
The downside is that the commit history can look a bit more messy.