0

I would like to list all commits on branch X that were first commited to that branch. E.g. I have a long living branch for a deployment environment. Most changes on that branch will enter there as merges from other branches, where they were developed. But some changes are done directly on the long living branch, those are the ones I'd like to list. Is that possible?

Tomas
  • 1,725
  • 2
  • 18
  • 27
  • Will `git log --first-parent --no-merges longlivedbranch --` do? – knittl Sep 02 '14 at 13:11
  • no, I'm seeing commits merged from other branches. No merge comments though. – Tomas Sep 02 '14 at 13:26
  • @Tomas Are you counting fast forward merges? – Emil Davtyan Sep 02 '14 at 13:56
  • 1
    Likely, git per se has no notion of "commit origin". If you still have "feature branches" you may list commits which are in the given branch, but not in feature branches. If you don't then you have to invent some other attribute (e.g. check commit messages) which could attribute a given commit to a feature-branch and not to your target branch. – user3159253 Sep 02 '14 at 13:59
  • @Emil doesn't matter if they are counted or not. – Tomas Sep 02 '14 at 15:09
  • @user3159253 yes, I see your point, also spoke to a colleague about this. It seems this is not possible unless you can compare branches in someway, which I can't at the state I'm in. Maybe its just me stuck in old school VCS, that figured this should work... – Tomas Sep 02 '14 at 15:11

1 Answers1

0

There really is no such thing. Ultimately, git's branches are really just data constructs within the commit graph. Branch names (labels) just give you entry points into the graph, with each commit carrying its parent ID(s) so as to construct the branch ancestry. In other words, branch names describe the tips of the various branches, but the branches themselves are largely independent of this.

See also this question (which is mostly its own answer) and my answer there.

You can add information to the commit graph (in commit message texts, or via git's "notes", for instance) to record "origins". This would allow you to achieve what you want. But git does not provide this directly.

Community
  • 1
  • 1
torek
  • 448,244
  • 59
  • 642
  • 775