How do I check if an old commit of a deleted branch that has been merged exists in develop?

162 Views Asked by At

Basically, I'm trying to write a script that ensures that a certain commit has been merged.

When i try to execute the command git branch --contains 0871b8479e6332ee3bd7a1ea9ea5b53795c3b3c5 in my terminal, I face the following error:

no such commit 0871b8479e6332ee3bd7a1ea9ea5b53795c3b3c5

This commit is the hash of one of the commits of a branch that has now been merged (and the branch was subsequently deleted). I need a way to confirm that this commit has been merged into the develop branch from shell script/github cli.

PS: I've tried using other branch based approached like git branch -a --merged, but I'm still not able to confirm that either my branch or my commit have been merged.

1

There are 1 best solutions below

0
On

How did you merge? "no such commit" makes me believe you "squash-merged" that branch. In that case you are out of luck. The commit is gone and you have no way to know into which commit it was squashed.

If you performed a "real" merge (creating a merge-commit with 2+ parents) or a fast-forward merge, then git branch --contains commit_id is the correct way to approach this.

Make sure to have fetched the remote history before running the command.