Code

Merge branch 'ap/branch-ref-display'
[git.git] / Documentation / git-clone.txt
1 git-clone(1)
2 ============
4 NAME
5 ----
6 git-clone - Clones a repository
9 SYNOPSIS
10 --------
11 [verse]
12 'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
13           [-o <name>] [-u <upload-pack>] [--reference <repository>]
14           [--use-separate-remote | --use-immingled-remote] <repository>
15           [<directory>]
17 DESCRIPTION
18 -----------
19 Clones a repository into a newly created directory.  All remote
20 branch heads are copied under `$GIT_DIR/refs/heads/`, except
21 that the remote `master` is also copied to `origin` branch.
23 In addition, `$GIT_DIR/remotes/origin` file is set up to have
24 this line:
26         Pull: master:origin
28 This is to help the typical workflow of working off of the
29 remote `master` branch.  Every time `git pull` without argument
30 is run, the progress on the remote `master` branch is tracked by
31 copying it into the local `origin` branch, and merged into the
32 branch you are currently working on.  Remote branches other than
33 `master` are also added there to be tracked.
36 OPTIONS
37 -------
38 --local::
39 -l::
40         When the repository to clone from is on a local machine,
41         this flag bypasses normal "git aware" transport
42         mechanism and clones the repository by making a copy of
43         HEAD and everything under objects and refs directories.
44         The files under .git/objects/ directory are hardlinked
45         to save space when possible.
47 --shared::
48 -s::
49         When the repository to clone is on the local machine,
50         instead of using hard links, automatically setup
51         .git/objects/info/alternates to share the objects
52         with the source repository.  The resulting repository
53         starts out without any object of its own.
55 --reference <repository>::
56         If the reference repository is on the local machine
57         automatically setup .git/objects/info/alternates to
58         obtain objects from the reference repository.  Using
59         an already existing repository as an alternate will
60         require less objects to be copied from the repository
61         being cloned, reducing network and local storage costs.
63 --quiet::
64 -q::
65         Operate quietly.  This flag is passed to "rsync" and
66         "git-fetch-pack" commands when given.
68 -n::
69         No checkout of HEAD is performed after the clone is complete.
71 --bare::
72         Make a 'bare' GIT repository.  That is, instead of
73         creating `<directory>` and placing the administrative
74         files in `<directory>/.git`, make the `<directory>`
75         itself the `$GIT_DIR`. This obviously implies the `-n`
76         because there is nowhere to check out the working tree.
77         Also the branch heads at the remote are copied directly
78         to corresponding local branch heads, without mapping
79         them to `refs/remotes/origin/`.  When this option is
80         used, neither the `origin` branch nor the default
81         `remotes/origin` file is created.
83 --origin <name>::
84 -o <name>::
85         Instead of using the branch name 'origin' to keep track
86         of the upstream repository, use <name> instead.  Note
87         that the shorthand name stored in `remotes/origin` is
88         not affected, but the local branch name to pull the
89         remote `master` branch into is.
91 --upload-pack <upload-pack>::
92 -u <upload-pack>::
93         When given, and the repository to clone from is handled
94         by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
95         the command to specify non-default path for the command
96         run on the other end.
98 --template=<template_directory>::
99         Specify the directory from which templates will be used;
100         if unset the templates are taken from the installation
101         defined default, typically `/usr/share/git-core/templates`.
103 --use-separate-remote::
104         Save remotes heads under `$GIT_DIR/remotes/origin/` instead
105         of `$GIT_DIR/refs/heads/`.  Only the local master branch is
106         saved in the latter. This is the default.
108 --use-immingled-remote::
109         Save remotes heads in the same namespace as the local
110         heads, `$GIT_DIR/refs/heads/'.  In regular repositories,
111         this is a legacy setup git-clone created by default in
112         older Git versions, and will be removed before the next
113         major release.
115 <repository>::
116         The (possibly remote) repository to clone from.  It can
117         be any URL git-fetch supports.
119 <directory>::
120         The name of a new directory to clone into.  The "humanish"
121         part of the source repository is used if no directory is
122         explicitly given ("repo" for "/path/to/repo.git" and "foo"
123         for "host.xz:foo/.git").  Cloning into an existing directory
124         is not allowed.
126 Examples
127 --------
129 Clone from upstream::
131 ------------
132 $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
133 $ cd my2.6
134 $ make
135 ------------
138 Make a local clone that borrows from the current directory, without checking things out::
140 ------------
141 $ git clone -l -s -n . ../copy
142 $ cd copy
143 $ git show-branch
144 ------------
147 Clone from upstream while borrowing from an existing local directory::
149 ------------
150 $ git clone --reference my2.6 \
151         git://git.kernel.org/pub/scm/.../linux-2.7 \
152         my2.7
153 $ cd my2.7
154 ------------
157 Create a bare repository to publish your changes to the public::
159 ------------
160 $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
161 ------------
164 Create a repository on the kernel.org machine that borrows from Linus::
166 ------------
167 $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
168     /pub/scm/.../me/subsys-2.6.git
169 ------------
172 Author
173 ------
174 Written by Linus Torvalds <torvalds@osdl.org>
177 Documentation
178 --------------
179 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
182 GIT
183 ---
184 Part of the gitlink:git[7] suite