Differences between revisions 3 and 4
Revision 3 as of 2012-04-28 14:24:25
Size: 2347
Editor: Tovim
Comment:
Revision 4 as of 2012-04-28 14:25:36
Size: 2339
Editor: Tovim
Comment:
Deletions are marked like this. Additions are marked like this.
Line 56: Line 56:
CategoryCzechTutorial CategoryCzech

Tutoriál 2 - Vytvoření repozitáře

Předchozí kapitolou je Instalace programu, další kapitolou je Klonování repozitáře)

In Mercurial, we do all of our work inside a repository. A repository is a directory that contains all of the source files that we want to keep history of, along with complete histories of those source files (inside the .hg directory — see UnderstandingMercurial).

Unlike some version control systems, you can create a repository in any directory you have write permissions to. All you have to do is initialize the repository, which will create a .hg subdirectory, and add some files to the repository.

To do this, we use the init command.1

Let's init a small "hello, world" repository in our file system.

(telephoto: /tmp) mkdir repo
(telephoto: /tmp) cd repo
/tmp/repo
(telephoto: /tmp/repo) ls
(telephoto: /tmp/repo) hg init

We can now see that our new repo has the .hg directory:

(telephoto: /tmp/repo) ls -a
./  ../  .hg/

We can now add some files to mercurial. In this example we're creating the files after we've initialized the repository, but that's not important in mercurial. One of the great things about mercurial is that it's easy to add version control to an existing directory structure. In either case, we just use "hg add" to place the files under version control.

(telephoto: /tmp/repo) touch hello.txt
(telephoto: /tmp/repo) ls
hello.txt
(telephoto: /tmp/repo) ls -a
./  ../  hello.txt  .hg/
(telephoto: /tmp/repo) hg add hello.txt

After adding the files they're not really "in" mercurial yet. For that we have to commit them:

(telephoto: /tmp/repo) hg commit -m "adding initial version of hello.txt"
(telephoto: /tmp/repo) ls -a
./  ../  hello.txt  .hg/
(telephoto: /tmp/repo) 

Nothing obvious changes about the files now that they've been committed, but this version of our files is now preserved in the repository.

Obvyklým způsobem použití Mercurialu je klonování repozitáře, který vytvořil někdo jiný. Ukážeme si to v následující kapitole Klonování repozitáře.


CategoryCzech

CzechTutorialInit (last edited 2013-12-28 19:28:34 by Tovim)