Since my comments seem to have answered your question, I will add them as an answer:
Merging is not really the right term to use in this scenario. The term that most closely describes a merge of a single commit is cherry-picking. If you want to have the contents of commit 1ab2cd3
on branch-b, you could use the following command while on branch-b:
git cherry-pick 1ab2cd3
Cherry-pick applies the changes introduced by the commit onto the current branch. This creates a new commit and is not a merge in terms of Git. Note that this will give the commit a different commit-hash. You cannot cherry-pick without changing the commit-hash (see this answer). However, the -x
argument can be used to put a reference to the original hash in the commit message of the commit produced by cherry-pick:
git cherry-pick -x 1ab2cd3
Addressing your question concerning which branch the commit will be taken from: A commit is identified by its hash which is identical in your local repository and on the remote. When you cherry-pick this commit, it takes the commit no matter on what branch(es) it is part of.