Check if the commit is merged with another branch, and if so, what is the merge?

Suppose git repo has two branches, master

and test

. commitA

runs on a branch test

. I want to test:

  • Is it connected commitA

    to a branch master

    ?
  • If so, what is the SHA merge?

I want to test this programmatically (not using gitk

).

+3


source to share


2 answers


There's a tool out there called git-when-merged

that was developed for exactly this use case. After installing it

git when-merged commitA master

      



must do the trick.

0


source


In your example, the branch is test

now in commit commitA

. So, you can check where commitA

was merged in master

with this command:

git branch --contains test

This list should list all branches containing commitA

, check if it is listed master

.



To get the SHA commitA

enter:

git rev-parse test

SHA commit and merge itself commitA

.

-1


source







All Articles