-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
executable file
·237 lines (227 loc) · 11.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>hg - the simple guide - no deep shit!</title>
<link href='http://fonts.googleapis.com/css?family=Chelsea+Market' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/0/normalize.min.css" type="text/css">
<link rel="stylesheet" href="css/style.css" type="text/css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-58178386-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
function recordOutboundLink(link, category, action) {
_gat._getTrackerByName()._trackEvent(category, action);
setTimeout('document.location = "' + link.href + '"', 100);
}
</script>
</head>
<body>
<div class="scrollblock block-title">
<h1>hg - the simple guide</h1>
<p>just a simple guide for getting started with hg. no deep shit ;)</p>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="xiaoganghan" data-size="large" data-url="http://chrishan.github.io/hg-guide/" data-related="xiaoganghan" data-hashtags="hg">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<p class="meta">
by <a href="https://twitter.com/xiaoganghan">Han Xiaogang</a>
<br />credits to <a href="http://www.twitter.com/rogerdudler">Roger Dudler</a><br />
please report issues on <a href="https://github.com/chrishan/hg-guide/issues">github</a>
</p>
<div class="announcement">
</div>
<img src="img/arrow.png" alt="" />
</div>
<!-- setup -->
<a name="setup"></a>
<div class="scrollblock block-setup">
<h2>setup</h2>
<p>
<a href="http://mercurial.selenic.com/downloads">Download hg for OSX/Windows/Linux</a>
</p>
</div>
<a name="create"></a>
<div class="scrollblock block-create">
<h2>create a new repository</h2>
<p>
create a new directory, open it and perform a <br />
<code>hg init</code><br />
to create a new hg repository.
</p>
</div>
<a name="checkout"></a>
<div class="scrollblock block-checkout">
<h2>checkout a repository</h2>
<p>
create a working copy of a local repository by running the command<br />
<code>hg clone /path/to/repository</code><br />
when using a remote server, your command will be<br />
<code>hg clone username@host:/path/to/repository</code>
</p>
</div>
<a name="trees"></a>
<div class="scrollblock block-trees">
<h2>workflow</h2>
<p>
Unlike git, which maintains three "trees" in your local repository: <code>Working Directory, Index, and HEAD</code>, Hg hides such it and handles it automatically so that the user don't need to deal with it.
</p>
<img src="img/trees.png" alt="" />
</div>
<a name="add"></a>
<div class="scrollblock block-add">
<h2>add & commit</h2>
<p>
You can propose changes (add it to the <b>Index</b>) using<br />
<code>hg add <filename></code><br />
<code>hg add</code><br />
This is the first step in the basic hg workflow. To actually commit these changes use<br />
<code>hg commit -m "Commit message"</code><br />
Now the file is committed to the <b>HEAD</b>, but not in your remote repository yet.
</p>
</div>
<a name="push"></a>
<div class="scrollblock block-remote">
<h2>pushing changes</h2>
<p>
Your changes are now in the <b>HEAD</b> of your local working copy. To send those changes to your remote repository, execute <br />
<code>hg push</code><br />
<code>hg push -b branch_name</code><br />
Change <i>master</i> to whatever branch you want to push your changes to.
<br /><br />
If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it in .hg/hgrc<br />
<code>[paths]</code><br />
<code>default = <server></code><br />
Now you are able to push your changes to the selected remote server<br />
</p>
</div>
<a name="branching"></a>
<div class="scrollblock block-branching">
<h2>branching</h2>
<p>
Branches are used to develop features isolated from each other. The <i>master</i> branch is the "default" branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion.
</p>
<img src="img/branches.png" alt="" />
<p>
create a new branch named "feature_x" and switch to it using<br />
<code>hg branch feature_x</code><br />
<code>hg commit -m "start feature_x branch"</code><br />
switch back to default<br />
<code>hg update default</code><br />
and close the branch<br />
<code>hg update feature_x</code><br />
<code>hg commit -m 'close feature_x' --close-branch</code><br />
a branch is <i>not available to others</i> unless you push the branch to your remote repository<br />
<code>hg push -b <branch></code>
</p>
</div>
<a name="update"></a>
<div class="scrollblock block-merging">
<h2>update & merge</h2>
<p>
to update your local repository to the newest commit, execute <br />
<code>hg pull</code><br />
in your working directory to <i>fetch</i> remote changes.<br />
and <i>merge</i> if necessary<br />
<code>hg merge</code><br />
to merge another branch into your active branch (e.g. master), use<br />
<code>hg merge <branch></code><br />
in both cases hg tries to auto-merge changes. Unfortunately, this is not always possible and results in <i>conflicts</i>.
You are responsible to merge those <i>conflicts</i>
manually by editing the files shown by hg. After changing, you need to commit the results of the merge with<br />
<code>hg commit -m "Merge message"</code><br />
before merging changes, you can also preview them by using<br />
<code>hg diff -r <source_branch>:<target_branch></code>
</p>
</div>
<a name="tagging"></a>
<div class="scrollblock block-tagging">
<h2>tagging</h2>
<p>
it's recommended to create tags for software releases. this is a known concept, which also exists in SVN. You can create a new tag named <i>1.0.0</i> by executing<br />
<code>hg tag -r 1b2e1d63ff 1.0.0</code><br />
<code>hg tag 1.0.0</code><br />
the <i>1b2e1d63ff</i> stands for the first 10 characters of the commit id you want to reference with your tag. You can get the commit id by looking at the... <br />
</p>
</div>
<a name="log"></a>
<div class="scrollblock block-log">
<h2>log</h2>
<p>
in its simplest form, you can study repository history using..
<code>hg log</code><br />
You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain author:<br />
<code>hg log -u bob</code><br />
These are just a few of the possible parameters you can use. For more, see
<code>hg help log</code><br />
</p>
</div>
<a name="checkout-replace"></a>
<div class="scrollblock block-checkout-replace">
<h2>replace local changes</h2>
<p>
In case you did something wrong (which for sure never happens ;) you can replace local changes using the command<br />
<code>hg update -C</code><br />
this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept.
</p>
<p>
If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this<br />
<code>hg pull</code><br />
<code>hg update -r default -C</code>
</p>
</div>
<!-- <a name="hints"></a>
<div class="scrollblock block-hints">
<h2>useful hints</h2>
<p>
first hint<br />
<code>hg</code><br />
</p>
</div> -->
<a name="resources"></a>
<div class="scrollblock block-resources">
<h2>links & resources</h2>
<h3>graphical clients</h3>
<p>
<ul>
<li><a href="http://www.sourcetreeapp.com/">Source Tree (OSX & Windows, free)</a></li>
</ul>
</p>
<h3>guides</h3>
<p>
<ul>
<li><a href="http://hginit.com/">Hg Init: a Mercurial tutorial</a></li>
<li><a href="http://mercurial.selenic.com/wiki/GitConcepts">Mercurial for Git users</a></li>
</ul>
</p>
<h3>get help</h3>
<p>
<ul>
<li><a href="http://mercurial.selenic.com/wiki/MailingLists">Hg User Mailing Lists</a></li>
</ul>
</p>
</div>
<a name="comments"></a>
<div class="scrollblock block-comments">
<h2>comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'hg-guide'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
<!-- <a href="http://www.git-tower.com/?source=rd" onClick="recordOutboundLink(this, 'Outbound Links', 'git-tower.com');return false;" class="tower"></a> -->
<!-- <a href="files/git_cheat_sheet.pdf" onClick="recordOutboundLink(this, 'Cheat Sheet', 'git-guide');return false;" class="cheatsheet"></a> -->
</body>
</html>