Differences between revisions 2 and 36 (spanning 34 versions)
Revision 2 as of 2005-08-26 01:05:08
Size: 1959
Editor: waste
Comment:
Revision 36 as of 2012-11-11 19:44:54
Size: 2843
Editor: abuehl
Comment: fix links
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== ["Tutorial"] - cloning a repository == == Tutorial - Cloning a Repository ==
''(This page is part of the [[Tutorial]] series. Previous part is TutorialInit, next part is TutorialHistory)''
Line 3: Line 4:
We have followed TutorialInstall to install ["Mercurial"] already, right? Good! You have followed TutorialInstall to install Mercurial already, right? Good!
Line 5: Line 6:
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. 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 7: Line 8:
The easiest way to get started with ["Mercurial"] is to use a ["Repository"] that already contains some files and some history. The easiest way to get started with Mercurial is to use a repository that already contains some files and some history.
Line 9: Line 10:
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. To do this, we use the {{{clone}}} command.<<FootNote([[Cmd:clone]])>> 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:
Line 12: Line 15:
 $ hg clone http://www.serpentine.com/hg/hello my-hello $ hg clone http://www.selenic.com/repo/hello my-hello
Line 14: Line 17:

['''Note''': sorry, but this isn't a real URL yet, because ["Mercurial"] doesn't yet allow you to ["Serve"] multiple repositories using a single daemon. I'm working on a fix.]

[Until this fix is in place, one can use
If all goes well, the {{{clone}}} command prints this (Mercurial 1.4):
Line 20: Line 20:
 $ hg clone http://selenic.com/hg my-hg-clone 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
Line 22: Line 28:

to try things out whith an already working repository. WARNING, this repository is not the smallest thing out there.]

If all goes well, the ''clone'' command prints no output. We should now find a directory called ''my-hello'' in our current directory:
We should now find a directory called {{{my-hello}}} in our current directory:
Line 28: Line 31:
 $ ls
 my-hello
$ ls
my-hello
Line 31: Line 34:

Inside the ''my-hello'' directory, we'll find some files:
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):
Line 35: Line 37:
 $ ls my-hello
 hello.c Makefile
$ ls -a
. .. .hg Makefile hello.c
Line 38: Line 40:
These files are exact copies of the files from the [[Tip|tip]] revision of the default branch in the repository we just cloned.
Line 39: Line 42:
These files are exact copies of the files in the ["Repository"] we just ["Clone"]d. '''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.
Line 41: Line 44:
'''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 default, `hg clone` checks out (see [[Cmd:update]]) the latest [[Revision|revision]] (usually referred to as the 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 parents command:<<FootNote([[Cmd:parents]])>>
Line 43: Line 46:
At this point, we can start examining some of the history of our new ["Repository"], by continuing to TutorialHistory. {{{
$ 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

Tutorial - Cloning a Repository

(This page is part of the Tutorial series. Previous part is TutorialInit, 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)