Unless you are using a pull-request flow, there is not any reliable mechanism to record which commits are done for a specific branch.
The name of a local branch is allowed to be arbitrary. You can create a local branch foo
, and push its new commits to the branch bar
. If the push succeeds, we can only be sure the commits are made for bar
. But it does not guarantee that the commits are made in a local bar
. If you are allowed to directly push foo
to bar
without a pull-request, the system even doesn't have a permanent record that these commits are pushed to bar
. You may find some clues in the commit message of a merge commit, but commit messages can be forged too, not to mention that you may not have strict format rules for commit messages. When the push is fast-forward, the merge commit itself does not even exist. The reflogs may have some clues too, but they are not reliable either as they are bound with local branches and not permanent.
With a systematic pull-request flow, the hosting services, like Github, Gerrit and Gitlab, have solid databases to record which commits are merged to a specific branch. They provide apis or interfaces, which allow users to retrieve these records from the databases.
In your case, you can try:
git log t1 ^master --first-parent --no-merges
But the result is not reliable in theory.