My dev branch is one more commit behind every pull request merge

I have a dev branch, a staging branch and temporary feature branches. Every time I merge a pull request from dev to staging the dev seems to be one more commit behind? I don’t understand whats happening. How can I fix this?

1 Like

You’ll have to check the history to be sure, but I assume that’s a merge commit created when you merge. :slightly_smiling_face:

1 Like

The screenshot message actually says 1 commit ahead and 22 behind.

There seem to be some serious synching problems between those two branches. Also, it’s not clear if this message refers to your local clone status or the status of the repository on GitHub.

As usual, links to actual repositories would help helper to help out.

1 Like

The dev branch is 2 commits ahead because I am adding new features (I will make a pull request when I finish) and its 32 commits behinds because I have merged 32 pull requests (Well I have made more pull requests but I accidentally deleted the dev branch so I had to make a new one)

This might depend on the merge strategy you’re using. By default, GitHub will create a merge commit for every PR merge (`–ff``), which is probably why you’re seeing the extra commit. I prefer to always use the Rebase-Merge strategy, which preserves a linear history.

You can change this in your repository settings, and decide which should be the default PR merging strategy. You can also enforce linear history in branch protection rules, so you don’t accidentally introduce those extra merge-commits.

https://www.bogotobogo.com/cplusplus/Git/Git_GitHub_Fast-Forward_Merge.php

1 Like