Skip to content

Commit 4c00709

Browse files
committed
started in on log
1 parent f8ded16 commit 4c00709

File tree

2 files changed

+134
-1
lines changed

2 files changed

+134
-1
lines changed

branching/index.html

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,142 @@ <h4>
458458
</pre>
459459

460460
<p>And now we've successfully resolved our merge conflict and committed
461-
the result.</p>
461+
the result.</p>
462+
463+
<p class="nutshell">
464+
<b>In a nutshell</b> you use <code>git merge</code> to combine another
465+
branch context into your current branch. It automatically figures out
466+
how to best combine the different snapshots into a new snapshot with the
467+
unique work of both.
468+
</p>
462469

463470
</div>
471+
</div>
472+
473+
<div class="box">
474+
<h2>
475+
<span class="docs">
476+
<a target="new" href="http://www.kernel.org/pub/software/scm/git/docs/git-log.html">docs</a> &nbsp;
477+
<a target="new" href="http://progit.org/book/">book</a>
478+
</span>
479+
<a name="branch">git log</a>
480+
<span class="desc">show commit history of a branch</span>
481+
</h2>
482+
483+
<div class="block">
484+
485+
<p>So far we have been committing snapshots of your project and switching
486+
between different isolated contexts, but what if we've forgotten how we've
487+
got to where we are? Or what if we want to know how one branch differs
488+
from another? Git provides a tool that shows you all the commit messages
489+
that have lead up to the snapshot you are currently on, which is called
490+
<code>git log</code>.</p>
491+
492+
<p>To understand the log command, you have to understand what information
493+
is stored when you run the <code>git commit</code> command to store a
494+
snapshot. In addition to the manifest of files and commit message and
495+
information about the person who committed it, Git also stores the commit
496+
that you based this snapshot on. That is, if you clone a project, what was
497+
the snapshot that you modified to get to the snapshot that you saved? This
498+
is helpful to give context to how the project got to where it is and allows
499+
Git to figure out who changed what. If Git has the snapshot you save and
500+
the one you based it on, then it can automatically figure out what you
501+
changed. The commit that a new commit was based on is called the "parent".
502+
</p>
503+
504+
<p>To see a chronological list of the parents of any branch, you can run
505+
<code>git log</code> when you are in that branch. For example, if we run
506+
<code>git log</code> in the Hello World project that we have been working
507+
on in this section, we'll see all the commit messages that we've done.
508+
509+
<pre>
510+
<b>$ git log</b>
511+
<span class="yellow">commit 8d585ea6faf99facd39b55d6f6a3b3f481ad0d3d</span>
512+
Merge: 3cbb6aa 3ac015d
513+
Author: Scott Chacon &lt;[email protected]>
514+
Date: Fri Jun 4 12:59:47 2010 +0200
515+
516+
Merge branch 'fix_readme'
517+
518+
Conflicts:
519+
README
520+
521+
<span class="yellow">commit 3cbb6aae5c0cbd711c098e113ae436801371c95e</span>
522+
Author: Scott Chacon &lt;[email protected]>
523+
Date: Fri Jun 4 12:58:53 2010 +0200
464524

525+
fixed readme title differently
526+
527+
<span class="yellow">commit 3ac015da8ade34d4c7ebeffa2053fcac33fb495b</span>
528+
Author: Scott Chacon &lt;[email protected]>
529+
Date: Fri Jun 4 12:58:36 2010 +0200
530+
531+
fixed readme title
532+
533+
<span class="yellow">commit 558151a95567ba4181bab5746bc8f34bd87143d6</span>
534+
Merge: b7ae93b 3467b0a
535+
Author: Scott Chacon &lt;[email protected]>
536+
Date: Fri Jun 4 12:37:05 2010 +0200
537+
538+
Merge branch 'change_class'
539+
...
540+
</pre>
541+
542+
<p>To see a more compact version of the same history, we can use the
543+
<code>--oneline</code> option.</p>
544+
545+
<pre>
546+
<b>$ git log --oneline</b>
547+
8d585ea Merge branch 'fix_readme'
548+
3cbb6aa fixed readme title differently
549+
3ac015d fixed readme title
550+
558151a Merge branch 'change_class'
551+
b7ae93b added from ruby
552+
3467b0a changed the class name
553+
17f4acf first commit
554+
</pre>
555+
556+
<p>What this is telling us is that this is the history of the development
557+
of this project. If the commit messages are descriptive, this can inform
558+
us as to what all changes have been applied or have influenced the current
559+
state of the snapshot and thus what is in it.</p>
560+
561+
<p>We can also use it to see when the history was branched and merged with
562+
the very helpful <code>--graph</code> option. Here is the same command
563+
but with the topology graph turned on:</p>
564+
565+
<pre>
566+
<b>$ git log --oneline --graph</b>
567+
* 8d585ea Merge branch 'fix_readme'
568+
|\
569+
| * 3ac015d fixed readme title
570+
* | 3cbb6aa fixed readme title differently
571+
|/
572+
* 558151a Merge branch 'change_class'
573+
|\
574+
| * 3467b0a changed the class name
575+
* | b7ae93b added from ruby
576+
|/
577+
* 17f4acf first commit
578+
</pre>
579+
580+
<p>Now we can more clearly see when effort diverged and then was merged
581+
back together. This is very nice for seeing what has happened or what
582+
changes are applied, but
583+
it is also incredibly useful for managing your branches. Let's create a new
584+
branch, do some work in it and then switch back and do some work in our
585+
master branch, then see how the <code>log</code> command can help us figure
586+
out what is happening on each.</p>
587+
588+
589+
<p class="nutshell">
590+
<b>In a nutshell</b> you use <code>git log</code> to list out the commit
591+
history or list of changes people have made that have lead to the snapshot
592+
at the tip of the branch. This allows you to see how the project in that
593+
context got to the state that it is currently in.
594+
</p>
595+
596+
</div>
465597
</div>
466598

467599
<p><a href="/basic">On to Sharing and Updating Projects &#187;</a></p>

css/layout.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pre b { color: #111; }
5858
.umber { color: #8A3324; }
5959
.lblue { color: #55a; }
6060
.blue { color: #447; }
61+
.yellow { color: #993; }
6162
.hl { background: #eea; }
6263

6364
.box h4 {

0 commit comments

Comments
 (0)