Differences between revisions 21 and 24 (spanning 3 versions)
Revision 21 as of 2008-09-11 22:31:38
Size: 2476
Editor: abuehl
Comment:
Revision 24 as of 2009-10-28 14:45:24
Size: 2524
Editor: abuehl
Comment: update to 1.4
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
''(This page is part 2 of 9 of the [:Tutorial] series. Previous part is [:TutorialInstall], next part is [:TutorialHistory])'' ''(This page is part 2 of 9 of the [[Tutorial]] series. Previous part is [[TutorialInstall]], next part is [[TutorialHistory]])''
Line 7: Line 7:
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. 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.
Line 11: Line 11:
To do this, we use the {{{clone}}} command. 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. To do this, we use the {{{clone}}} command. 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.
Line 19: Line 19:
If all goes well, the {{{clone}}} command prints this (Mercurial 1.0): If all goes well, the {{{clone}}} command prints this (Mercurial 1.4):
Line 27: Line 27:
updating working directory updating to branch default
Line 47: Line 47:
'''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]. '''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]].
Line 49: Line 49:
By default, `hg clone` checks out (see [:Update]) the [:Tip:tip]most [:Revision:revision] of the repository
into the repository's [:WorkingDirectory:working directory]. To see which revision is currently checked out,
we can use the [:Parent:parents] command:
By default, `hg clone` checks out (see [[Update]]) the [[Tip|tip]]most [[Revision|revision]] 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:
Line 54: Line 54:
$ cd my-hello

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.

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

$ ls my-hello
Makefile  hello.c

These files are exact copies of the files 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 tipmost revision 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:

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