Advertising

> 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.