I’ve played around with three version control systems during my learning and working period. The first was CVS, where it was the first time I’ve touched a version-control mechanism during university. The second being Mercurial and lastly, Git; two of which I’ve learnt partially for supporting customers while I was working with Atlassian.
Now as I’m in a developer’s role, I would feel the need to pick up a version-control system as what most developers do. Thus, I re-learnt Mercurial once more.
There are a few basic commands that one should know and understand for a better understanding on how Mercurial works. Here’s a list of common commands that I’ve stumbled upon thus far.
- initialize the current directory to be a repo
hg add %FILE_NAME%
%FILE_NAME% to the repo
hg commit -m "%YOUR_MESSAGE%"
- confirms changes to the repo
-m argument: for adding a commit message to the commit
hg clone %REPO_URL% %NEW_FOLDER%
- for cloning online repos
%REPO_URL% = repo URL
hg clone %CUR_REPO% %NEW_REPO%
- for cloning existing local repo to a new one
%CUR_REPO% = repo to clone
%NEW_REPO% = destination for the clone repo
hg parents or
- to view which revision is currently checked out
hg log -v
hg log -r%CHANGESET_ID%
hg log -r%CHANGESET_ID% -p
- show patches associated with the changesets:
$ hg log -r1 -p
date: Fri Aug 26 01:21:28 2005 -0700
summary: Create a makefile
diff -r 0a04b987be5a -r 82e55d328c8c Makefile
--- /dev/null Fri Aug 26 01:20:50 2005 -0700
+++ b/Makefile Fri Aug 26 01:21:28 2005 -0700
@@ -0,0 +1,1 @@
hg tip or
hg log -r tip
hg status or
- shows the status of files in the repo.
- a few denotations:
|untracked in repo (not added)
- a detailed view of the actual changes made to files:
$ hg diff
diff -r 82e55d328c8c hello.c
--- a/hello.c Fri Aug 26 01:21:28 2005 -0700
+++ b/hello.c Mon May 05 00:27:56 2008 +0200
@@ -12,5 +12,6 @@
int main(int argc, char **argv)
+ printf("sure am glad I'm using Mercurial!\n");
hg revert %FILE_NAME%
%FILE_NAME% to its unmodified state.
- to modify all files, replace
- creating a changeset.
- enter any message(s) on the first line.
- grab latest changesets that does not exist in the current repo.
- can specify a path for a specific repo.
hg update or
- updates the current repo with changes pulled from another.
Was That a Good Read? Rate It!