My branches have diveregd after a squash and merge. How do I fix that ?

I did a ‘Squash and merge’ to close a PR. Although all the changes are now present in both the develop and master, it still says the branches have diverged and there are still changes ahead and behind the default branch.

This branch is 1 commit ahead, 28 commits behind develop.

How do I fix this? The 28 commits are the commits which were squashed during ‘squash and merge’.

I assumed that squash and merge would do a fast forward merge to prevent the divergence. I don’t want all the commits from develop to move to master, which is why I did a “squash and merge”, instead of rebasing.

“Squash” in git terms means to combine a set of commits into one, that contains only the sum of changes, which is why you have only one new commit on the master branch.

If you want to keep the commits unchanged (which I generally consider a good idea!) and merge over the web GUI, you need to do a merge with a merge commit (see documentation on merging pull requests). As far as I’m aware there is no way to do a fast-forward merge (without merge commit or rebase/squash) directly from a GitHub pull request, if that’s what you want you’ll have to merge locally and push to master.

Ok. So I was reading the docs at . It says "Pull requests with squashed commits are merged using the fast-forward option".  Doesn’t that mean that the branches will be even ?

No. It only means the squashed commit will be added directly on top of to the target branch, without a merge commit.

I totally get it now. Although I would say that the wording ‘squash and merge’ is a bit misleading.