Squash & Merge (as a Pull Request) missing commit from tip of branch

Yesterday, in response to a Pull Request, I did a Squash/Merge from a dev_branch to master.

When I look at the Pull Request (now closed), it shows the “Merged” tag and correctly lists the 10 commits (shows commit messages/ids) that went into the merge. As expected, the last one listed is the tip of dev_branch. When I select the link to that commit, it correctly shows that the last commit on dev_branch consisted exclusively of the deletion of 3 unused files.

When I go to the master branch, and examine the commit corresponding to the aforementioned merge/pull request, the comments show the appropriate/same 10 commit messages from the merge. But the list of files changed does not include the 3 that were deleted by the last commit on dev_branch. So, the files are still present on master.

There seems to be a mis-match between what happened with the Squash/Merge and what happened with the Pull.

Is this a bug in GitHub’s Pull/Merge functionality? Or am I missing something?

Okay, I can answer this myself…
TLDR: noob error.

Full answer:
I had copied an intermediate commit on the dev_branch to a dev_branch2.
dev_branch2 at that point included the creation of the aforementioned 3 files.
dev_branch2 was subsequently merged to master. So far so good…

The problem I described arose from me squash/merging the tip of dev_branch, which included the entire set of commits, including:

  • one commit (also on dev_branch2) that created the 3 files
  • another commit that deleted the 3 files

The squash/merge correctly saw that the files were both created and deleted, which effectively squashed to no change. That’s why the final commit didn’t include the delete.

Ultimately, the problem occurred because of the way I did the two squash/merges. In the future I will use a different process, namely cherry-picking the later dev_branch commits to a new branch, then squash/merging that.

1 Like