comparison hgscm/templates/quick_start.html @ 204:3989294c82e4

Turned the quick start into HTML
author Arne Babenhauserheide <bab@draketo.de>
date Thu, 02 Jul 2009 14:42:04 +0200
parents text/quick_start.txt@7ad3b0348ffc text/quick_start.txt@e25c49f3fe47
children c1c9a4f809ba
comparison
equal deleted inserted replaced
201:b96a398de44c 204:3989294c82e4
1 <h1>Quick Start</h1>
2 <p><em>How to get going at once.</em></p>
3 <h2>Part 0: Instant usage</h2>
4 <p><em>(you know this from the main page)</em></p>
5 <p>Clone a project and create a patch </p>
6 <pre><code>$ hg clone http://hg-scm.org/hello
7 $ cd hello
8 $ (edit files)
9 $ hg add (new files)
10 $ hg commit -m 'My changes'
11 $ hg export tip &gt; patch.diff
12 </code></pre>
13 <p>Create a project and commit </p>
14 <pre><code>$ hg init (project-directory)
15 $ cd (project-directory)
16 $ (add some files)
17 $ hg add
18 $ hg commit -m 'Initial commit'
19 </code></pre>
20 <h2>Part 1: Using Mercurial</h2>
21 <p>Aside from the practical Quick Start above, there are only a few commands you need to start working. </p>
22 <p>Even if you stick to these basics, Mercurial is quite powerful. And they are very easy to use, once you see the model behind that: Each repository has the whole history, and history is not necessarily linear (part 2 explains that model in a bit more detail). </p>
23 <p>A quick overview of the basic commands: </p>
24 <ul>
25 <li>hg init: create a new repository
26 </li><li>hg commit: save your changes in the current repository
27 </li><li>hg log: see all changes in your repository
28 </li><li>hg pull: get all changes from another repository int the current one
29 </li><li>hg push: get all changes from your repository into another one
30 </li><li>hg serve: create an instant-webserver. People can see the history there and pull from it
31 </li><li>hg merge: join different lines of history
32 </li>
33 </ul>
34 <p>If you want to see a nice graph of the history, just do "hg serve" in your repository and then direct your browser to </p>
35 <pre><code> http://127.0.0.1:8000
36 </code></pre>
37 <p>This also helps getting a feeling for what the commands do. </p>
38 <p>(you can also do a lot of finegrained stuff by using different command options. Just call "hg help <command>" to see them). </p>
39 <p>One step you'll likely want to do is setting your username in your Mercurial config file. </p>
40 <p>For this you can configure a proper name and email address in ~/.hgrc (or on a Windows system in %USERPROFILE%Mercurial.ini) by adding lines such as the following: </p>
41 <pre><code>[ui]
42 username = John Doe &lt;john@example.com&gt;
43 </code></pre>
44 <p>I you want more than this quick overview, please have a look at our longer <a href="{% url workflow_guide %}">practical guide</a>. </p>
45 <h2>Part 2: Understanding Mercurial in 6 steps</h2>
46 <p>Now we'll look at some of the basic concepts of Mercurial to get a better understanding of its internals: </p>
47 <ol>
48 <li>
49 <p>Like in Subversion, history consists of a number of commits. They're
50 called changesets in Mercurial.</p>
51
52 </li><li>
53 <p>Subversion requires a strict linear ordering of the commits and
54 gives nice linear revision numbers to them. So revision N has only
55 one child revision, N+1. This is simple, but it requires a central server to make sure that
56 everybody agrees on the revision numbers.</p>
57
58 </li><li>
59 <p>Mercurial generalizes this by letting each changeset have multiple
60 children. If I work alone and make commits I'll make</p>
61 <p>C1 --&gt; C2 --&gt; C3</p>
62 <p>by making three commits. </p>
63
64 <p>The commit C3 with no children is a "head".
65 It is also the newest changeset in the repository -- called "tip". If I shared C1 with you and you started your work from that, your
66 commits will build a repository like this:</p>
67 <pre><code>C1 --&gt; C2' --&gt; C3'
68 </code></pre>
69 <p>Here C3' is a head in your repository and I don't know anything
70 about C2' and C3' yet.</p>
71
72 </li><li>If I pull from you, or you push to me, the two repositories are
73 compared. By default, all missing changesets are transferred. This
74 is all there is to push/pull: compare two graphs of changesets and
75 transfer the missing ones.
76 <p>After a pull from you my repository will look like this:</p>
77 <pre><code> /-&gt; C2 --&gt; C3
78 C1 -&lt;
79 \-&gt; C2' --&gt; C3'
80 </code></pre>
81 <p>Here C1 has two child changesets, and the repository has two heads
82 since the development has diverged.</p>
83 <p>The changeset C3' will be the new tip since it is the newest
84 changeset in the repository. Note that tip is always a head, but a
85 head need not be the tip.</p>
86
87 </li><li>Having two heads suggest that someone should merge them -- otherwise
88 the changes from one will never be combined with the changed made in
89 the other head.
90 <p>When merging with 'hg merge' the task is to figure out the canonical
91 way to combine the changesets. If the changes do not overlap this is
92 usually trivial, otherwise you have to do a three-way merge. The
93 merge must be committed and this creates a changeset which explains
94 to the world how you think the two heads should be combined:</p>
95 <pre><code> /-&gt; C2 --&gt; C3 -\
96 C1 -&lt; &gt;-&gt; M
97 \-&gt; C2' --&gt; C3' -/
98 </code></pre>
99 <p>Note that the merge changeset M has two parents.</p>
100 <p>If you do not merge C3 and C3' and try to push, you get the 'new
101 remote head' message and push aborts. It aborts since it is a little
102 "impolite" to leave the job of merging to someone else -- he who
103 created the two heads by pulling in some code should also normally
104 do the merging.
105 </p>
106 </li><li>
107 <p>It helped my understanding a lot to think in terms of the changeset graph. Just remember that:</p>
108 <ul><li>
109 <p>"hg commit" adds a new node. The parent changesets of the new node
110 is given by "hg parents"</p>
111
112 </li><li>
113 <p>"hg push" and "hg pull" transfer nodes in the graph between two
114 repositories.</p>
115
116 </li><li>
117 <p>"hg update" updates the working copy to reflect a given node in
118 the history graph. This also changes the parent changeset of the
119 next commit, see "hg parents".</p>
120 </li>
121 </ul>
122 </ol>
123
124 <p>And if you want to quickly look up something, you can use one of the <a href="http://www.selenic.com/mercurial/wiki/index.cgi/QuickReferenceCardsAndCheatSheets">Mercurial cheatsheets</a>. </p>
125 <p><em>Compiled from a great email by Martin Geisler.</em></p>