Mercurial: Difference between revisions

From Wiki
Jump to navigation Jump to search
Line 23: Line 23:
</pre>
</pre>


=== Status ===
=== Status, Diff, Remove, Add ===
<pre>
<pre>
> cp a.txt b.txt
> cp a.txt b.txt
> emacs a.txt
> emacs a.txt
> rm favicon.ico
> rm favicon.ico
> hg status
M a.txt                  # Modified
? b.txt                  # "?" means mercurial doesn't know anything about this file yet
! favicon.ico            # "!" means missing
>
> hg diff a.txt          # show differences between last snapshot and current version
> hg remove favicon.ico  # really remove this file
> hg add                  # add all new files to repository
> hg status
> hg status
M a.txt
M a.txt
! favicon.ico
A b.txt                  # Added
? b.txt
R favicon.ico             # Removed
</pre>
</pre>
"M" means modified, "!" means missing, "?" means mercurial doesn't know anything about this file yet.

Revision as of 00:02, 8 November 2012

Client

http://hginit.com/

The command for Mercurial is hg.

Create a repository

Suppose you want to set up version control for the my_code directory.

cd my_code
hg init    # creates .hg directory
hg add     # adds everything from the current directory
hg commit  # has you enter a text description, then creates a first snapshot of the directory


Commit, Revert, Log

hg commit        # has you enter a text description, then creates a snapshot of the directory
hg revert --all  # reverts everything back to the last commit
hg log           # shows a list of all commits

Status, Diff, Remove, Add

> cp a.txt b.txt
> emacs a.txt
> rm favicon.ico
> hg status
M a.txt                   # Modified
? b.txt                   # "?" means mercurial doesn't know anything about this file yet
! favicon.ico             # "!" means missing
>
> hg diff a.txt           # show differences between last snapshot and current version
> hg remove favicon.ico   # really remove this file
> hg add                  # add all new files to repository
> hg status
M a.txt
A b.txt                   # Added
R favicon.ico             # Removed