@matheusbsbs / matheus-bagliano / commits / dc29bc8bd2
Fork 0

tutorial: clarify "pull" is "fetch + merge"

The document says that a fetch with a configured remote stores what are fetched in the remote tracking branches "Unlike the longhand form", but there is no longhand form "fetch" demonstrated earlier. This adds a missing demonstration of the longhand form, and a new paragraph to explain why some people might want to fetch before pull. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jul 10, 2008 at 14:01 UTC dc29bc8bd243fcd20815c7dddc15dbae30747c28
1 file changed +27 -1
Documentation/gittutorial.txt
+27 -1
@@ -306,6 +306,32 @@ is the default.)
306 The "pull" command thus performs two operations: it fetches changes
307 from a remote branch, then merges them into the current branch.
308
309 +Note that in general, Alice would want her local changes committed before
310 +initiating this "pull". If Bob's work conflicts with what Alice did since
311 +their histories forked, Alice will use her working tree and the index to
312 +resolve conflicts, and existing local changes will interfere with the
313 +conflict resolution process (git will still perform the fetch but will
314 +refuse to merge --- Alice will have to get rid of her local changes in
315 +some way and pull again when this happens).
316 +
317 +Alice can peek at what Bob did without merging first, using the "fetch"
318 +command; this allows Alice to inspect what Bob did, using a special
319 +symbol "FETCH_HEAD", in order to determine if he has anything worth
320 +pulling, like this:
321 +
322 +------------------------------------------------
323 +alice$ git fetch /home/bob/myrepo master
324 +alice$ git log -p ..FETCH_HEAD
325 +------------------------------------------------
326 +
327 +This operation is safe even if Alice has uncommitted local changes.
328 +
329 +After inspecting what Bob did, if there is nothing urgent, Alice may
330 +decide to continue working without pulling from Bob. If Bob's history
331 +does have something Alice would immediately need, Alice may choose to
332 +stash her work-in-progress first, do a "pull", and then finally unstash
333 +her work-in-progress on top of the resulting history.
334 +
335 When you are working in a small closely knit group, it is not
336 unusual to interact with the same repository over and over
337 again. By defining 'remote' repository shorthand, you can make
@@ -315,7 +341,7 @@ it easier:
341 alice$ git remote add bob /home/bob/myrepo
342 ------------------------------------------------
343
318 -With this, Alice can perform the first operation alone using the
344 +With this, Alice can perform the first part of the "pull" operation alone using the
345 'git-fetch' command without merging them with her own branch,
346 using:
347