From: "Steven E. Harris" <seh@panix.com>
To: git@vger.kernel.org
Subject: How does git follow branch history across a merge commit?
Date: Fri, 28 Aug 2009 18:37:59 -0400 [thread overview]
Message-ID: <8363c75zug.fsf@torus.sehlabs.com> (raw)
This question concerns git's representation of merge commits.
I understand that branches in git are references to commit vertices in a
graph, that each of these vertices have zero or more reference edges to
a parent (predecessor) vertex, and that merges create vertices with at
least two parents. Walking back in time from a branch head involves
traversing parent edges.
But what happens when such traversal reaches a merge commit? If one asks
git to move back, say, in time by a few days, or so many predecessors,
how does it know (or choose) which way to go upon reaching a merge
commit?
I set up an experiment with two competing branches that require merging
back together:
,----
| mkdir gitexp && cd gitexp && git init
| $EDITOR file1.txt
| git add file1.txt
| git commit -m'Initial impound.'
| $EDITOR file1.txt
| git commit -a -m'Added a second line.'
|
| git checkout -b competition
| $EDITOR file1.txt
| git commit -a -m'Extended second line.'
|
| git checkout master
| $EDITOR file1.txt
| git commit -a -m'Added third line.'
|
| git checkout competition
| $EDITOR file1.txt
| git commit -a -m'Edited second line.'
| $EDITOR file1.txt
| git commit -a -m'Added an alternate third line.'
|
| git checkout master
| git merge competition
| # Edit to resolve conflict:
| $EDITOR file1.txt
| git commit -a
|
| git checkout 'HEAD^'
| # At this point, git picked the predecessor along branch "master".
`----
Was it just luck that "HEAD^" referred to the predecessor that came from
branch "master" rather than branch "competition"?
--
Steven E. Harris
next reply other threads:[~2009-08-28 23:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-28 22:37 Steven E. Harris [this message]
2009-08-28 23:30 ` How does git follow branch history across a merge commit? Junio C Hamano
2009-08-28 23:32 ` Junio C Hamano
2009-08-28 23:50 ` Steven E. Harris
2009-08-29 0:01 ` Junio C Hamano
2009-08-30 0:29 ` Steven E. Harris
2009-08-29 0:25 ` Björn Steinbrink
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8363c75zug.fsf@torus.sehlabs.com \
--to=seh@panix.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.