gitgithubgit-mergegit-squash

git thinks branch missing commits merged earlier


My team has recently transitioned to a GitHub Actions CI/CD workflow and we are encountering an issue that I'm uncertain how best to resolve.

First, I'll describe our current branching strategy:

We are a Salesforce stack shop that uses the Org Development model. This means that each developer has their own sandbox, and in addition we have Integration, UAT, and Production environments.

We have created 3 long-lived branches in git that are meant to represent each of these non-developer sandboxes (int, uat, main). The intended workflow is as follows:

The issue we have encountered is that after a feature branch has been merged into both int and main, our int branch still seems to think that it is behind the main branch. Example:

Looking into it, I can see that commit1 has a different hash in the int branch than the one in main. So, I believe I understand why git does not see these as the same commit, but I'm unsure what has caused the hash to change.

I'm certain I'm overlooking something here, or perhaps misunderstanding what is happening with git behind the scenes. Any help would be greatly appreciated.


Solution

  • Once squashed ...

    Stop doing that.

    In the same way that adding comments as a deodorant to cover up stinking code is a bad idea, squashing branches because the version history stinks is also a bad idea (and that is always the reasoning behind why people want to squash branches on pull requests, although expressed as an euphemism like "clean up the branch" or whatever).

    Using fixup or squash in interactive rebase while working on a feature is not only perfectly fine (I am in no way advocating that commits are immutable and should never be changed), but more than that - almost required. However at the point when creating a pull request the history should be clean and proper (including all commits pass tests) and squashing is wrong.

    Squashing will ruin your ability to drill down problems with git bisect. And as you have experienced it also breaks your workflow.