From: Jakub Narebski <jnareb@gmail.com>
To: Jon Forrest <nobozo@gmail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: More Beginning Git Questions
Date: Fri, 23 Sep 2011 10:42:18 -0700 (PDT) [thread overview]
Message-ID: <m3ipojqhpm.fsf@localhost.localdomain> (raw)
In-Reply-To: <4E7C9AAD.7060209@gmail.com>
Jon Forrest <nobozo@gmail.com> writes:
> I'm reading the git tutorial at
> http://schacon.github.com/git/gittutorial.html
I recommend reading "Pro Git" book (http://progit.org)
> I'm a very literal reader so if something isn't clear
> to me, I try to make the effort to understand it.
>
> In reading about what happens when Alice pulls from Bob,
> it says:
>
> "Note that in general, Alice would want her local changes committed
> before initiating this "pull"."
>
> This is an interesting statement. I'll come back to it shortly.
>
> "If Bobs work conflicts with what Alice did since their histories forked,"
>
> Does this include both changes that Alice has checked in to
> her repository and uncommitted changes in her working tree?
Generally Alice shouldn't have uncommitted changes when doing
"git pull".
> "Alice will use her working tree and the index to resolve conflicts,"
>
> How does Alice use her working tree and index? Does this mean
> she makes changes to her working tree so that the conflicts
> no longer exist? How does the index play a part in this?
> I thought that the index gets populated only when a
> "git add" is done. Does Alice need to do "git add" as part
> of the conflict resolution process?
This is actually a very important information.
When there is a merge conflicts, the index gets populated by more than
one version: "ours" (i.e. Alice version) in stage 2, "theirs"
(i.e. Bob version) in stage 3, and "base" (common ancestor version) in
stage 1. The stage 0, where "git add" / "git stage" puts contents of
file, is empty.
You can see it using "git ls-files --abbrev --stage".
The working area gets populated with version that contains both "ours"
and "theirs" hunks using conflict markers (the 3-way textual merge,
like 'rcsmerge' or 'diff3 -E' does). Sidenote: you can use "git
checkout --conflict=merge <file>" to re-create this version if you
messed up conflict resolution, or even --conflict=diff3 if you want
"base" (ancestor) version to be shown in conflict markers as
well... but this would discard your changes.
After resolving conflict you do "git add" on resolved file to mark it
as done. This leaves you with only newly add-ed stage 0 in the index!
The pre-commit hook might check if you didn't accidentally marked as
resolved (added) file with [something that looks like] conflict
markers in it.
HTH
--
Jakub Narębski
next prev parent reply other threads:[~2011-09-23 17:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-23 14:41 More Beginning Git Questions Jon Forrest
2011-09-23 16:11 ` Matthieu Moy
2011-09-23 17:42 ` Jakub Narebski [this message]
2011-09-23 18:14 ` Jon Forrest
2011-09-23 18:44 ` Mihamina Rakotomandimby
2011-09-23 18:59 ` Jakub Narebski
2011-09-24 20:22 ` tactical
2011-09-24 20:53 ` Frans Klaver
2011-09-24 22:17 ` tactical
2011-09-24 22:59 ` Seth Robertson
2011-09-25 2:16 ` tactical
2011-09-25 13:22 ` Jakub Narebski
2011-09-25 20:23 ` tactical
2011-09-25 20:58 ` Jakub Narebski
2011-09-25 21:07 ` tactical
2011-09-26 0:34 ` Konstantin Khomoutov
2011-09-26 0:56 ` tactical
2011-09-26 1:34 ` Andrew Ardill
2011-09-26 1:42 ` tactical
2011-09-26 18:03 ` Jakub Narebski
2011-09-24 21:10 ` Jakub Narebski
2011-09-24 22:10 ` tactical
2011-09-25 13:24 ` Jakub Narebski
2011-09-23 18:47 ` Junio C Hamano
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=m3ipojqhpm.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=nobozo@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).