14. % hg
Mercurial Distributed SCM
basic commands:
add add the specified files on the next commit
annotate show changeset information by line for each file
clone make a copy of an existing repository
commit commit the specified files or all outstanding changes
diff diff repository (or selected files)
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
summary summarize working directory state
update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
15. % pwd
/Users/neo/Code/Repo/hginit
% ll
total 24
drwxr-xr-x 5 neo staff 170 Aug 7 13:13 .
drwxr-xr-x 12 neo staff 408 Aug 7 13:11 ..
-rw-r--r--@ 1 neo staff 1605 Jun 26 12:23 Info.plist
-rw-r--r--@ 1 neo staff 2907 Jun 19 16:18 global.html
-rw-r--r-- 1 neo staff 1183 Jun 12 16:22 link.png
% hg init
% ll
total 24
drwxr-xr-x 6 neo staff 204 Aug 7 13:14 .
drwxr-xr-x 12 neo staff 408 Aug 7 13:11 ..
drwxr-xr-x 5 neo staff 170 Aug 7 13:14 .hg
-rw-r--r--@ 1 neo staff 1605 Jun 26 12:23 Info.plist
-rw-r--r--@ 1 neo staff 2907 Jun 19 16:18 global.html
-rw-r--r-- 1 neo staff 1183 Jun 12 16:22 link.png
16. % hg add
adding Info.plist
adding global.html
adding link.png
% hg commit
% hg log
changeset: 0:0ae94e57c184
% hg commit
tag: tip
Info.plist
user: "Neo Lee <neo.lee at gmail.com>"
global.html
date: Sat Aug 07 14:43:24 2010 +0800
link.png
files: Info.plist global.html link.png
committed changeset 0:0ae94e57c184
description:
Init commit.
17.
18. % hg commit
% hg log
changeset: 1:dc12cb350527
tag: tip
user: "Neo Lee <neo.lee at gmail.com>"
date: Sat Aug 07 14:54:57 2010 +0800
files: global.html
description:
Capitalize 'ERROR' prompt.
changeset: 0:0ae94e57c184
user: "Neo Lee <neo.lee at gmail.com>"
date: Sat Aug 07 14:43:24 2010 +0800
files: Info.plist global.html link.png
description:
Init commit.
21. % cp Info.plist Info.plist.1
% e Info.plist
% rm link.png
remove link.png? y
% hg status
M Info.plist
! link.png
? Info.plist.1
% hg diff Info.plist
diff -r dc12cb350527 Info.plist
--- a/Info.plist Sat Aug 07 14:54:57 2010 +0800
+++ b/Info.plist Sat Aug 07 15:07:18 2010 +0800
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>Author</key>
- <string>Neo Lee</string>
+ <string>Li Jun</string>
<key>CFBundleDisplayName</key>
<string>Goo.gl</string>
<key>CFBundleIdentifier</key>
22. % hg log
changeset: 2:5ba69dac6378
tag: tip
user: "Neo Lee <neo.lee at gmail.com>"
% hg remove link.png
date: Sat Aug 07 15:10:02 2010 +0800
removing link.png
files: Info.plist Info.plist.1 link.png
description:
% hg status
Some dirty work!
M Info.plist
R link.png
? Info.plist.1
changeset: 1:dc12cb350527
user: "Neo Lee <neo.lee at gmail.com>"
% hg add
date: Sat Aug 07 14:54:57 2010 +0800
adding Info.plist.1
files: global.html
description:
% hg st
Capitalize 'ERROR' prompt.
M Info.plist
A Info.plist.1
R link.png
changeset: 0:0ae94e57c184
user: "Neo Lee <neo.lee at gmail.com>"
% hg commit
date: Sat Aug 07 14:43:24 2010 +0800
files: Info.plist global.html link.png
description:
Init commit.
30. % hg outgoing
comparing with http://8.oasis.local:8000/
searching for changes
changeset: 2:689026657682
tag: tip
user: Rose M <rose@snda.com>
date: Mon Feb 08 15:29:09 2010 -0500
Rose summary: Spicier kind of chile.
% hg push
pushing to http://8.oasis.local:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
31. % hg outgoing
comparing with http://8.oasis.local:8000/
searching for changes
changeset: 2:4ecdb2401ab4
tag: tip
user: Joel S <joel@snda.com>
date: Mon Feb 08 15:32:01 2010 -0500
summary: potato chips. No one can eat just one.
% hg push
pushing to http://8.oasis.local:8000/
searching for changes
abort: push creates new remote heads!
(did you forget to merge? use push -f to force)
% hg incoming
Joel comparing with http://8.oasis.local:8000/
searching for changes
changeset: 3:689026657682
tag: tip
parent: 1:a52881ed530d
user: Rose M <rose@example.com>
date: Mon Feb 08 15:29:09 2010 -0500
summary: spicier kind of chile
% hg pull
pulling from http://8.oasis.local:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
32. % hg merge
merging guac
0 files updated, 1 files merged, 0 files removed, 0
files unresolved
(branch merge, don't forget to commit)
% hg commit -m "merge"
% hg log
changeset: 4:0849ca96c304
tag: tip
parent: 2:4ecdb2401ab4
parent: 3:689026657682
user: Joel S <joel@snda.com>
date: Mon Feb 08 16:07:23 2010 -0500
summary: merge
Joel ... ...
% hg out
comparing with http://8.oasis.local:8000//
searching for changes
changeset: 2:4ecdb2401ab4
... ...
changeset: 4:0849ca96c304
... ...
% hg push
pushing to http://8.oasis.local:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
33. Rose
% hg pull
pulling from http://8.oasis.local:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
(run 'hg update' to get a working copy)
% hg log
% hg parent
changeset: 2:689026657682
user: Rose H <rose@snda.com>
date: Mon Feb 08 15:29:09 2010 -0500
summary: spicier kind of chile
% hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
44. References
• Mercurial: The Definitive Guide
by Bryan O'Sullivan, http://hgbook.red-bean.com/
• Hg Init: a Mercurial tutorial
by Joel Spolsky, http://hginit.com/top/index.html
• Git for the Lazy
by Spheriki, http://www.spheredev.org/wiki/Git_for_the_lazy
• PeepCode Git Internals
by Scott Chacon