Mercurial: Difference between revisions

From Open Source Ecology
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
URL: http://mercurial.selenic.com/
URL: http://mercurial.selenic.com/


==Main Links==
* http://hginit.com - a Mercurial tutorial by Joel Spolsky
* Online book: [http://hgbook.red-bean.com/read/ Mercurial: The Definitive Guide]
* Quick start: http://mercurial.selenic.com/wiki/QuickStart
* Basic introduction to version control and Mercurial: http://www.soton.ac.uk/~fangohr/computing/Mercurial/talk.pdf


==Basic Concepts==
==Basic Concepts==
* '''Working copy''': Root folder where your project files are located;
* '''Working copy''': Root folder where your project files are located;
* '''Repository''': Inside every '''working copy''' folder, there's an '''.hg''' folder, which is an Hg repository. It stores all change history of your files. Every project developer has one. You can also choose to have a ''main'' repository in a specific computer.
 
* '''Repository''' (a.k.a. ''repo''): Inside every '''working copy''' folder, there's an '''.hg''' folder, which is an Hg repository. It stores all change history of your files. Every project developer has one. You can also choose to have a ''main'' repository in a specific computer.
 
* '''.hgignore''': Similar to ''.cvsignore''. Located at the root of the '''working copy'''. Specifies which files to ignore.
* '''.hgignore''': Similar to ''.cvsignore''. Located at the root of the '''working copy'''. Specifies which files to ignore.
* '''commit''': Stores inside the '''.hg''' folder (i.e. the ''local'' '''repository''') the changes made to the '''working copy'''. A '''commit''' is stored as a new '''changeset''';
* '''commit''': Stores inside the '''.hg''' folder (i.e. the ''local'' '''repository''') the changes made to the '''working copy'''. A '''commit''' is stored as a new '''changeset''';
* '''changeset''': Conveys the changes made to a previous state of the '''repository'''. Each changeset has a changeset '''id''', which is a globally unique identifier. Each changeset has a comment;
* '''changeset''': Conveys the changes made to a previous state of the '''repository'''. Each changeset has a changeset '''id''', which is a globally unique identifier. Each changeset has a comment;
* '''pull''': Brings changesets from a different '''repository''' to your local one (only changesets that you don't already have);
 
* '''push''': Sends changesets from you local '''repository''' to a different one (only changesets that don't already exist on the other repository);
* '''pull''': Brings '''changesets''' from a different '''repository''' to your local one (only changesets that you don't already have);
 
* '''push''': Sends '''changesets''' from you local '''repository''' to a different one (only changesets that don't already exist on the other repository);
 
* '''clone''': Similar to SVN's ''checkout'' command. When you want to work on a project that you don't have, you '''clone''' the project's '''repository'''
 
 
==Quick Start==
 
* Create a project and '''commit'''
$ hg init ''(project-directory)''
$ cd ''(project-directory)''
$ ''(add some files)''
$ hg add
$ hg '''commit''' -m 'Initial commit'
* '''Clone''' a project and '''push''' changes
$ hg '''clone''' http://selenic.com/repo/hello
$ cd hello
$ ''(edit files)''
$ hg add ''(new files)''
$ hg '''commit''' -m 'My changes'
$ hg '''push'''
 
 
==Main Links==
* http://hginit.com - an excellent Mercurial tutorial by Joel Spolsky
* Online book: [http://hgbook.red-bean.com/read/ Mercurial: The Definitive Guide]
* Quick start: http://mercurial.selenic.com/wiki/QuickStart
* Basic introduction to version control and Mercurial: http://www.soton.ac.uk/~fangohr/computing/Mercurial/talk.pdf
 


==More Information==
==More Information==
Line 28: Line 56:
* [http://mercurial.selenic.com/wiki/SubversionToMercurialHowto From SVN to Mercurial HOWTO]
* [http://mercurial.selenic.com/wiki/SubversionToMercurialHowto From SVN to Mercurial HOWTO]
* [http://stackoverflow.com/questions/448567/best-practices-in-mercurial-branch-vs-clone-and-partial-merges Best practices in mercurial: branch vs. clone, and partial merges?]
* [http://stackoverflow.com/questions/448567/best-practices-in-mercurial-branch-vs-clone-and-partial-merges Best practices in mercurial: branch vs. clone, and partial merges?]


==See Also==
==See Also==
Line 33: Line 62:


[[Category: Software]]
[[Category: Software]]
[[Category: Crash Course]]

Latest revision as of 03:55, 31 March 2011

Mercurial, a.k.a. Hg, is a distributed source control management tool

URL: http://mercurial.selenic.com/


Basic Concepts

  • Working copy: Root folder where your project files are located;
  • Repository (a.k.a. repo): Inside every working copy folder, there's an .hg folder, which is an Hg repository. It stores all change history of your files. Every project developer has one. You can also choose to have a main repository in a specific computer.
  • .hgignore: Similar to .cvsignore. Located at the root of the working copy. Specifies which files to ignore.
  • commit: Stores inside the .hg folder (i.e. the local repository) the changes made to the working copy. A commit is stored as a new changeset;
  • changeset: Conveys the changes made to a previous state of the repository. Each changeset has a changeset id, which is a globally unique identifier. Each changeset has a comment;
  • pull: Brings changesets from a different repository to your local one (only changesets that you don't already have);
  • push: Sends changesets from you local repository to a different one (only changesets that don't already exist on the other repository);
  • clone: Similar to SVN's checkout command. When you want to work on a project that you don't have, you clone the project's repository


Quick Start

  • Create a project and commit
$ hg init (project-directory)
$ cd (project-directory)
$ (add some files)
$ hg add
$ hg commit -m 'Initial commit'
  • Clone a project and push changes
$ hg clone http://selenic.com/repo/hello
$ cd hello
$ (edit files)
$ hg add (new files)
$ hg commit -m 'My changes'
$ hg push


Main Links


More Information


See Also

  • Pacha - Uses Mercurial to backup and manage software configuration files from single or multiple server instances across the network.