$ hg init # Quickly check what commands are available $ hg help # Get help on a specific command # hg help $ hg help add $ hg help commit $ hg help init # Will display the status of files $ hg status # Get help on the status subcommand $ hg help status # Add a file in the current directory $ hg add filename.rb # Add a file in a sub directory $ hg add foo/bar/filename.rb # Add files by pattern $ hg add *.rb # With no argument it shows the current branch name $ hg branch # With a name argument it will change the current branch. $ hg branch new_branch marked working directory as branch new_branch (branches are permanent and global, did you want a bookmark?) # List tags $ hg tags tip 2:efc8222cd1fb v1.0 0:37e9b57123b3 # Create a new tag on the current revision $ hg tag v1.1 # Create a tag on a specific revision $ hg tag -r efc8222cd1fb v1.1.1 # Clone a remote repo to a local directory $ hg clone https://some-mercurial-server.example.com/reponame # Clone a local repo to a remote server $ hg clone . ssh://username@some-mercurial-server.example.com/newrepo # Clone a local repo to a local repo $ hg clone . /tmp/some_backup_dir # Commit with a message $ hg commit -m 'This is a commit message' # Commit all added / removed files in the current tree $ hg commit -A 'Adding and removing all existing files in the tree' # amend the parent of the working directory with a new commit that contains the # changes in the parent in addition to those currently reported by 'hg status', $ hg commit --amend -m "Correct message" # Show the diff between the current directory and a previous revision $ hg diff -r 10 # Show the diff between two previous revisions $ hg diff -r 30 -r 20 # Search files for a specific phrase $ hg grep "TODO:" # Show the history of the entire repository $ hg log # Show the history of a single file $ hg log myfile.rb # Show the revision changes as an ASCII art DAG with the most recent changeset # at the top. $ hg log -G # Merge changesets to local repository $ hg merge # Merge from a named branch or revision into the current local branch $ hg merge branchname_or_revision # After successful merge, commit the changes hg commit # Rename a single file $ hg mv foo.txt bar.txt # Rename a directory $ hg mv some_directory new_directory # List remote paths $ hg paths remote1 = http://path/to/remote1 remote2 = http://path/to/remote2 # Pull from remote 1 $ hg pull remote1 # Pull from remote 2 $ hg pull remote2 # List remote paths $ hg paths remote1 = http://path/to/remote1 remote2 = http://path/to/remote2 # Pull from remote 1 $ hg push remote1 # Pull from remote 2 $ hg push remote2 # Put the commits into draft status # This will draft all subsequent commits on the relevant branch $ hg phase --draft --force -r 1206 # Rebase from from revision 102 over revision 208 $ hg rebase -s 102 -d 208 # Reset a specific file to its checked out state $ hg revert oops_i_did_it_again.txt # Revert a specific file to its checked out state without leaving a .orig file # around $ hg revert -C oops_i_did_it_again.txt # Revert all changes $ hg revert -a # Remove a specific file $ hg remove go_away.txt # Remove a group of files by pattern $ hg remove *.txt