My branches have diveregd after a squash and merge. How do I fix that ? #23249
-
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.
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. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
“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. |
Beta Was this translation helpful? Give feedback.
-
Ok. So I was reading the docs at https://help.github.com/en/github/administering-a-repository/about-merge-methods-on-github#squashing-your-merge-commits . It says "Pull requests with squashed commits are merged using the fast-forward option". Doesn’t that mean that the branches will be even ? |
Beta Was this translation helpful? Give feedback.
-
No. It only means the squashed commit will be added directly on top of to the target branch, without a merge commit. |
Beta Was this translation helpful? Give feedback.
-
I totally get it now. Although I would say that the wording ‘squash and merge’ is a bit misleading. |
Beta Was this translation helpful? Give feedback.
No. It only means the squashed commit will be added directly on top of to the target branch, without a merge commit.