Reputation: 16395
Let's say I've got the following commits in my master
branch.
a <- b <- c <- d <- e
Then I create another branch called feature
. I make a single commit on this branch. It looks like this.
<- f
a <- b <- c <- d <- e
When using the list commits api I can get all commits for my feature
branch. Is there a way to see from the result that my commit f
is on the feature
branch and the rest is in master?
Or do I have to make another request to the compare two commits api? In the end I'd like to have all commits (a
- f
) with the branch they belong to.
Edit:
m
stands for master
and f
for feature
.
branch: m <- m <- m <- m <- m <- f
commit: a <- b <- c <- d <- e <- f
Upvotes: 2
Views: 704
Reputation: 488043
(You already discovered the compare API; I include it below because it seems weird that they use another syntax.)
Commits A through E are in branch feature
.
This is a big surprise to those used to other version control systems in which a commit is in exactly one branch. In Git, commits are in zero or more branches.
To list commits that are in feature
but are not in master
, you tell Git: Collect a set of all commits in feature
. Collect a second set of all commits in master
. Subtract the second set away from the first set, and show me the resulting set.
The command-line syntax for this is master..feature
or feature ^master
. Note that there are two, not three, dots between the two names. The three-dot syntax exists as well, with a different meaning (symmetric difference—which is a superset of the two-dot meaning, but requires left side / right side indicators to be used to obtain the two-dot meaning).
The GitHub API page suggests a REST API that may be equivalent. Curiously, the REST API uses the three-dot syntax, but the description says it produces the same result as the two-dot syntax. Whether it does, I do not know.
Upvotes: 2