Differences between revisions 27 and 30 (spanning 3 versions)
Revision 27 as of 2009-11-22 16:03:53
Size: 2635
Editor: Tovim
Comment:
Revision 30 as of 2011-01-30 04:36:59
Size: 2998
Editor: rcl
Comment: rephrased statement about tip
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Tutoriál - Klonování repozitáře == == Tutorial - Cloning a Repository ==
Line 3: Line 3:
''(Toto je druhá část řady 1-9 [[Tutorial]]. Předcho je[[TutorialInstall]], následuje [[TutorialHistory]])'' ''(This page is part 2 of 9 of the [[Tutorial]] series. Previous part is [[TutorialInstall]], next part is [[TutorialHistory]])''
Line 5: Line 5:
Aplikaci Mercurial (nebo TortoiseHg) máme řádně nainstalovánu? Dobrá, popojedeme. You have followed TutorialInstall to install Mercurial already, right? Good!
Line 7: Line 7:
V Mercurialu se všechno důležité odehrává uvnitř [[Repository|repozitáře]]. Přísně vzato, repozitář je složka s označením {{{.hg}}}, umístěná spolu s pracovními (a dalšími) soubory uvnitř našeho pracovního adresáře.
Nejjednodušší způsob jak začít s Mercurialem, je použít kopii projektu s již vytvořeným repozitářem.
In Mercurial, we do all of our work inside a [[Repository|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).
Line 10: Line 10:
Použijeme k tomu příkaz {{{clone}}}.<<FootNote(http://www.selenic.com/mercurial/hg.1.html#clone)>> Ten vytvoří [[Clone|klon]] buď celého pracovního adresáře nebo jenom repozitáře, v závislosti na tvaru příkazu. The easiest way to get started with Mercurial is to use a repository that already contains some files and some history.
Line 12: Line 12:
Pořiďme si kopii nevelkého projektu, kterou uložíme do samočinně vytvořené složky mojeHalo na aktuálním disku: To do this, we use the {{{clone}}} command.<<FootNote(http://www.selenic.com/mercurial/hg.1.html#clone)>> This makes a [[Clone|clone]] of a repository; it makes a complete copy of another repository so that we will have our own local, private one to work in.

Let's clone a small "hello, world" repository hosted at selenic.com:
Line 15: Line 17:
> hg clone http://www.selenic.com/repo/hello mojeHalo $ hg clone http://www.selenic.com/repo/hello my-hello
Line 18: Line 20:
Půjde-li vše dobře, příkaz {{{clone}}} vytiskne toto (Mercurial 1.4): If all goes well, the {{{clone}}} command prints this (Mercurial 1.4):
Line 30: Line 32:
Na disku C:\ bychom nyní měli nalézt nový adresář {{{mojeHalo}}}, jehož obsah prozkoumáme otvíráním jednotlivých položek nebo příkazem: We should now find a directory called {{{my-hello}}} in our current directory:
Line 32: Line 35:
> dir mojeHalo $ ls
my-hello
Line 35: Line 39:
Uvnitř adresáře {{{mojeHalo}}} nalezneme dva soubory `hello.c`}, `Makefile` a složku `.hg`, která obsahuje historii repozitáře plus různé interní informace -- více viz[[Repository]].

Tyto soubory jsou přesnou kopií souborů z poslední ([[Tip|tip]]) revize původní větve klonovaného repozitáře.<<br>>
Informace o kopírované verzi repozitáře získáme příkazem[[Parent|parents]] :<<FootNote(http://www.selenic.com/mercurial/hg.1.html#parents)>>
Inside the {{{my-hello}}} directory, we should find some files, together with the .hg directory, that contains
Mercurial's private data (basically the history of the repository plus various state information &mdash; see [[Repository]] for more information):
Line 41: Line 43:
> cd mojeHalo
> hg parents
$ ls -a
. .. .hg Makefile hello.c
}}}

These files are exact copies of the files from the [[Tip|tip]] revision of the default branch in the repository we just cloned.

'''Note:''' in Mercurial, each repository is self-contained. When you clone a repository, the new repository becomes an exact copy of the existing one at the time of the clone, but subsequent changes in either one ''will not show up'' in the other unless you explicitly transfer them, by either [[Pull|pulling]] or [[Push|pushing]].

By default, `hg clone` checks out (see [[Update]]) the latest [[Revision|revision]] (usually referred to as the [[Tip|tip]]) of the repository's ''default branch''
into the repository's [[WorkingDirectory|working directory]]. To see which revision is currently checked out,
we can use the [[Parent|parents]] command:<<FootNote(http://www.selenic.com/mercurial/hg.1.html#parents)>>

{{{
$ cd my-hello
$ hg parents
Line 50: Line 65:
'''Note:''' V okamžiku provedeného klonování jsou oba repozitáře totožné. Později se zřejmě oba repozitáře nezávisle na sobě různě změní. Změny lze z jednoho repozitáře do druhého přenést přikazy
[[Pull|pull]] nebo [[Push|push]] -- viz dále.

Nyní se již můžeme pustit do zkoumání historie našeho nového repozitáře na další stránce -- TutorialHistory.
At this point, we can start examining some of the history of our new repository, by continuing to TutorialHistory.

Tutorial - Cloning a Repository

(This page is part 2 of 9 of the Tutorial series. Previous part is TutorialInstall, next part is TutorialHistory)

You have followed TutorialInstall to install Mercurial already, right? Good!

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).

The easiest way to get started with Mercurial is to use a repository that already contains some files and some history.

To do this, we use the clone command.1 This makes a clone of a repository; it makes a complete copy of another repository so that we will have our own local, private one to work in.

Let's clone a small "hello, world" repository hosted at selenic.com:

$ hg clone http://www.selenic.com/repo/hello my-hello

If all goes well, the clone command prints this (Mercurial 1.4):

requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved

We should now find a directory called my-hello in our current directory:

$ ls
my-hello

Inside the my-hello directory, we should find some files, together with the .hg directory, that contains Mercurial's private data (basically the history of the repository plus various state information — see Repository for more information):

$ ls -a
.  ..  .hg  Makefile  hello.c

These files are exact copies of the files from the tip revision of the default branch in the repository we just cloned.

Note: in Mercurial, each repository is self-contained. When you clone a repository, the new repository becomes an exact copy of the existing one at the time of the clone, but subsequent changes in either one will not show up in the other unless you explicitly transfer them, by either pulling or pushing.

By default, hg clone checks out (see Update) the latest revision (usually referred to as the tip) of the repository's default branch into the repository's working directory. To see which revision is currently checked out, we can use the parents command:2

$ cd my-hello
$ hg parents
changeset:   1:82e55d328c8c
tag:         tip
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

At this point, we can start examining some of the history of our new repository, by continuing to TutorialHistory.


CategoryTutorial

TutorialClone (last edited 2015-10-28 15:22:27 by alishamsulqamar)