Re: [git-users] Git branch history

2016-04-12 Thread Konstantin Khomoutov
On Tue, 12 Apr 2016 05:08:52 -0700 (PDT)
Kevin Wholley  wrote:

> I would like to see a history of any branch that merges into another 
> branch. For example I have master as my production code. I also have
> a build branch and several development branches. When a development
> branch is ready to build we merge into our build branch. At this
> point this command is fine "git branch –merged" however, when the
> development branch changes and the commit point moves this command
> does not list the branch(s) that merged to the build branch. I need
> to know all the changes merged in from the dev branches to the build
> branch regardless if the commit point changes, kind of like a full
> history of the build branch. Is this possible? How is it done?

Well, I'd recommend you to delve into the "gitrevisions" manual page
(run `git help revisions`).

There are three major facts about how Git stores your history:

* All commits form a so-called "direct acyclic graph" (DAG) with
  commits being vertexes of that graph and their child→parent
  relations being its edges.

* Given any commit (vertex) on that DAG, it's possible to trace its
  full history through those child→parent relations (edges).

  Note that since there may be true merge commits in the graph, and
  they have two or more parents.

  Also note that Git is fine with merging initially disjoint histories,
  and so tracing through the history might led you to several "root"
  commits (those with no parents).

* A branch (or a tag) merely points to a single commit on the history
  graph.  Commits themselves are not in any way marked as "belonging"
  to a branch (or a tag).

What follows from all of the above, is that in Git, you should stop
thinking about the history as a flat timeline but rather twist your
brain to think about it as a subgraph or a full history graph.

This will allow you to understand why Git uses the "sets algebra" on
commits of your history graph when you tell it to traverse your history.

So basically the statement "I need to know all the changes merged in
from the dev branches to the build branch regardless if the commit
point changes" is solved like this:

* Get the last merged point between "dev" and "master":

git merge-base dev master

* Follow the chain of commits made on "dev" off that point.
  Assuming you did merge "dev" into "master" (and not vice-versa),
  you'd do

git log $(git merge-base dev master)^2

Having said that, I'd say you might be approaching the problem from the
wrong side: with Git, it's more typical to ask "what history is on the
A branch which is not merged into the B brach" which is queried via

  git log A ^B

or

  git log A..B

You might find the "--contains" command-line option of the `git branch`
command useful as well.

Be also sure to check out more advanced ways to specify revisions in the
gitrevisions manual page.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Git branch history

2016-04-12 Thread Kevin Wholley
Thanks. This is actually does provide some value. The downside is if I 
merge to my build branch or my dev branches from master (production code) 
it brings all those commit with it that are already in prod but unrelated 
to the work so it is messy.
I need to parse that in some way so I only have the relevant merges for the 
current development and builds. Thanks for a pointer on this

On Tuesday, April 12, 2016 at 10:30:25 AM UTC-4, Dale R. Worley wrote:
>
> Kevin Wholley  writes: 
> > I would like to see a history of any branch that merges into another 
> > branch. For example I have master as my production code. I also have a 
> > build branch and several development branches. When a development branch 
> is 
> > ready to build we merge into our build branch. At this point this 
> command 
> > is fine "git branch --merged" however, when the development branch 
> changes 
> > and the commit point moves this command does not list the branch(s) that 
> > merged to the build branch. I need to know all the changes merged in 
> from 
> > the dev branches to the build branch regardless if the commit point 
> > changes, kind of like a full history of the build branch. Is this 
> possible? 
> > How is it done? 
>
> If I understand you correctly, I think "git log --graph " 
> will show you the history of the chosen branch with all merges going 
> into it.  What it doesn't do is label which ancestory commits are "part 
> of which branches".  In Git, that isn't a well-defined concept; commits 
> exist in a directed acyclic graph, and branches are pointers to 
> commits.  So the commit "my-branch^" doesn't *belong* to my-branch, 
> though in fact that commit may be reachable only from the commit 
> my-branch. 
>
> (Though it would help if "git log --graph" would label commits that are 
> branch heads.) 
>
> Dale 
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Git branch history

2016-04-12 Thread Dale R. Worley
Kevin Wholley  writes:
> I would like to see a history of any branch that merges into another 
> branch. For example I have master as my production code. I also have a 
> build branch and several development branches. When a development branch is 
> ready to build we merge into our build branch. At this point this command 
> is fine "git branch --merged" however, when the development branch changes 
> and the commit point moves this command does not list the branch(s) that 
> merged to the build branch. I need to know all the changes merged in from 
> the dev branches to the build branch regardless if the commit point 
> changes, kind of like a full history of the build branch. Is this possible? 
> How is it done?

If I understand you correctly, I think "git log --graph "
will show you the history of the chosen branch with all merges going
into it.  What it doesn't do is label which ancestory commits are "part
of which branches".  In Git, that isn't a well-defined concept; commits
exist in a directed acyclic graph, and branches are pointers to
commits.  So the commit "my-branch^" doesn't *belong* to my-branch,
though in fact that commit may be reachable only from the commit
my-branch.

(Though it would help if "git log --graph" would label commits that are
branch heads.)

Dale

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.