Mercurial

From eBabel wiki
Jump to: navigation, search

Add a new file

hg add path-to-file-name

Remove a file that has been added

hg remove path-to-file-name

Commit changes to existing files

hg record

Note: the record extension may need to be enabled in ~/.hgrc

[extensions]
record =

Record: examine changes

When prompted with Ynesfdaq, answer with one letter:

  • y: Yes, record this change
  • n: No, skip this change
  • e: Edit this change manually using a text editor
  • s: Skip remaining changes to this file
  • f: Record remaining changes to this file
  • d: Done, skip remaining changes and files
  • a: Record all changes to all remaining files
  • q: Quit, recording no changes

Change the editor used by hg

select-editor

Fetch everything from remote repos

hg pull

Note: This is the equivalent of git fetch

Refetching a locally deleted file from the Mercurial remote repository

hg revert path-to-file-name

Permission denied

Check if you own the folder or the file that hg can't update. It is likely you don't own it.

ls -al folder-name
sudo chown -R your-username:your-group folder-name

or

ls -al file-name
sudo chown your-username:your-group file-name

Revert non-commited changes

hg pull
hg update -r BRANCHNAME -C

List changes

hg status

As long a change is not recorded with hg record, it will be listed in hg status

Get the status

hg sum

Note: this is the equivalent of git status.

List all branches

hg branches

Show current branch

hg branch

Checkout an existing branch

hg checkout branch-name

Create a new branch from the current branch

hg pull
hg up branch-to-create-from
hg branch name-of-new-branch

Warning: it isn't possible to push that branch until some changes have been committed to it. The first time it is pushed with hg push, you will need the flag --new-branch

hg push --new-branch

Note: --new-branch is not to be changed to the name of the branch, it is always called "--new-branch".

Install Mercurial

Ubuntu 16.04 Mercural Install

How do I install Mercurial on Ubuntu? Can I work with it command line like I would with Git?

MacOS or Windows Mercurial Install

Use SourceTree to easily install everything that's needed: https://www.sourcetreeapp.com/download/