Monday, September 24, 2018

The Savior Commands of Hg : Mercurial

Hi all,


I am back after a long time. Many of you have been using HG / Mercurial for repository work. So here goes the list of commands that I find useful and handy:

[ui]
username = swati <swati.srivastava@gmail.com>

$ hg clone <repo url> 
-- Clone from a URL


$ hg st
-- Get the status/list of all uncommitted changes


$ hg st -a
-- Get the status/list of all added files


$ hg st -m
-- Get the status/list of all modified files


$ hg st -r
-- Get the status/list of all removed files


$ hg heads
-- Get the list of all heads



$ hg tip

-- Get the latest revision of the current branch


$ hg addremove
-- Adds new files and removes the deleted files from your file system


$ hg commit -m "commit message"
-- Commit the data/files with a message


$ hg pull
-- Fetches all the code/files committed by other on all branches



$ hg update
-- Updates the working copy with the latest code


$ hg update tip
-- Updates the working copy with the latest code of the tip


$ hg update -r <revision no>
-- Updates the working copy with the latest code of the revision no mentioned


$ hg push
-- Push your committed code


$ hg push -r <revision no>
-- Push your committed code of a particular version


$ hg merge
-- Merge the code


$ hg revert
-- Undo / Discard all the uncommitted changes


$ hg strip <changeset>
-- Srips / removes the particular changeset. This may lead to error
hg : unknown command named strip
'strip' is provided by the following extension mq : manage stack of patches

Solution: open .hgrc file and write
[extensions]
mq = 



$ hg rollback
-- Rollbacks an accidental commit


$ hg diff -r<revision 1> -r<revision 2>
-- Provides difference between 2 revisions


$ hg help
-- Get a help on all types of available commands