From: Junio C Hamano <junkio@cox.net>
To: Jon Loeliger <jdl@freescale.com>
Cc: git@vger.kernel.org
Subject: Re: Now What?
Date: Thu, 03 Nov 2005 00:58:50 -0800 [thread overview]
Message-ID: <7vvezajeet.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <E1EXTw5-00063o-Gt@jdl.com> (Jon Loeliger's message of "Wed, 02 Nov 2005 19:30:37 -0600")
Jon Loeliger <jdl@freescale.com> writes:
> I feel that an explanation of all of the behind-the-scripts-
> in-.git communication files is needed. In particular these:
>
> FETCH_HEAD
> MERGE_HEAD
> LAST_MERGE
> MERGE_MSG
>
> These need to be mentioned and explained because they
> frequently form exactly the critical missing link or
> starting point after a failed fetch or merge.
I am not so sure if it would help to know details of the above
four files to answer "Now What" question, but I'll try to
describe them near the end of this message.
Before that, here is a cookbook failed pull/merge resolution
procedure.
$ git pull some-where
Gaah ... resolve by hand.
Oops, it failed. Now what?
First, if your index did not match your HEAD before
pulling/merging, the merge strategies will refuse to merge in
the changes and would fail without touching your working tree
(so you would not even see "resolve by hand" message). If you
want to proceed, you need to somehow match your HEAD and your
index to retry. There are two possibilities.
(1) if you were deep in a middle of something, snapshot your
changes and rewind the current tree.
$ git commit -a -m 'WIP'
$ git branch save-wip
$ git reset --hard HEAD^
and then retry merge or pull. Later you would want to
resurrect what you did from save-wip branch (e.g. "git diff
save-wip^ save-wip | git apply" after finishing your
merge).
(2) if you did not have much worth saving, just rewind the
changes. Optionally you could save the diff just in case.
$ git diff HEAD >tmp-wip.diff
$ git reset --hard
and then retry merge or pull.
Now that case is out of our way, I'll discuss the case where
your index did match your HEAD from here on. You pulled from
remote, merge strategy tried to do its work, and did not find a
clean automerge.
At this point, the automerge procedure would have already
updated your index for paths that cleanly merged. The rest are
left in your working tree, so this diff would show what remains
to be resolved:
$ git diff
You would most likely see some <<<< ==== >>>> conflict markers.
Resolving them by hand is hopefully something familiar to CVS or
SVN migrants, so "Now what" document may not have to talk about
what these conflict markers mean ("between <<<< and ==== are
your version, between ==== and >>>> are their version", or
something like that --- I may be getting this particular detail
wrong in this sentence, so you should check).
After resolving them by hand, you would want to see what got
changed from _your_ version for sanity checking, because you are
hopefully more familiar with your version than theirs, and
reading diff between theirs might be more difficult. So check
$ git diff HEAD
to see what changes this pull brought in, including the conflict
resolution you just did. On the other hand,
$ git diff MERGE_HEAD
would show diff from their head, so you would see what you did
to their tree.
After checking the diffs, if things look OK, compiling and
testing is the same procedure as you would normally do before
making any commit. Then
$ git commit -a
(as usual, you can drop '-a' if you manually 'git-update-index'
all the necessary paths before this step) would give you the
regular commit message editor, with a reminder "you are
committing a merge", with prepared message "merge from
some-where repository". Edit it and exit the editor normally to
make the merge commit, and you are done.
Now to the communication files.
> FETCH_HEAD
This file lists refs the git-fetch command (run from git-pull)
retrieved from the remote. Usually it marks everything but one
as 'not-for-merge'. The one that is not marked as
'not-for-merge' is the commit you are merging into the current
head. This is not looked at by the merge machinery, but
git-pull uses it to decide which commits to pass to git-merge.
> MERGE_HEAD
This is present only after a failed automerge, by git-merge, and
lists the commits that you are merging into the current head
(typically only one) -- the same as the ones not marked as
'not-for-merge' in FETCH_HEAD, because this file records the
commits given to git-merge.
> LAST_MERGE
This is more or less historical curiosity and only git-resolve
uses it. Records almost the same information as MERGE_HEAD.
> MERGE_MSG
This is created by git-pull from FETCH_HEAD to format a human
readable autocommit log.
> Finally, a procedure or style question. Should this
> write-up be in the form of a structured FAQ? A stand-alone
> expository document?
One useful thing would be to have a cut&paste ready example that
would cover constructing two branches/repos, pulling a branch
from one to the other and causing an actual conflict, and show
how to resolve it and make a commit, in a section in Tutorial.
I think we already have something like that there.
Another good thing would be, after proofreading this message and
making necessary corrections, send it as a patch form to add it
as a new file under Documentation/howto/.
next prev parent reply other threads:[~2005-11-03 8:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-03 1:30 Now What? Jon Loeliger
2005-11-03 1:43 ` Chris Shoemaker
2005-11-03 9:00 ` Junio C Hamano
2005-11-03 18:51 ` Jon Loeliger
2005-11-06 20:33 ` Junio C Hamano
2005-11-03 8:38 ` Peter Eriksen
2005-11-03 10:00 ` Junio C Hamano
2005-11-03 17:05 ` Daniel Barkalow
2005-11-03 17:27 ` Linus Torvalds
2005-11-03 18:38 ` Junio C Hamano
2005-11-03 17:30 ` Peter Eriksen
2005-11-03 22:07 ` Junio C Hamano
2005-11-03 22:33 ` Josef Weidendorfer
2005-11-04 17:06 ` Daniel Barkalow
2005-11-03 17:25 ` Linus Torvalds
2005-11-03 8:58 ` Junio C Hamano [this message]
2005-11-03 20:55 ` Junio C Hamano
2005-11-03 22:17 ` Josef Weidendorfer
2005-11-03 22:51 ` Junio C Hamano
2005-11-03 23:26 ` Josef Weidendorfer
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=7vvezajeet.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=jdl@freescale.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).