]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-clone.txt
Minor grammar fixes for git-diff-index.txt
[thirdparty/git.git] / Documentation / git-clone.txt
CommitLineData
215a7ad1
JH
1git-clone(1)
2============
6ec311da
JH
3
4NAME
5----
7bd7f280 6git-clone - Clones a repository
6ec311da
JH
7
8
9SYNOPSIS
10--------
353ce815 11[verse]
a57c8bac
JH
12'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
13 [-o <name>] [-u <upload-pack>] [--reference <repository>]
fb6a9f93 14 [--use-separate-remote] <repository> [<directory>]
6ec311da
JH
15
16DESCRIPTION
17-----------
4607166d
JH
18Clones a repository into a newly created directory. All remote
19branch heads are copied under `$GIT_DIR/refs/heads/`, except
20that the remote `master` is also copied to `origin` branch.
21
22In addition, `$GIT_DIR/remotes/origin` file is set up to have
23this line:
24
25 Pull: master:origin
26
27This is to help the typical workflow of working off of the
28remote `master` branch. Every time `git pull` without argument
29is run, the progress on the remote `master` branch is tracked by
30copying it into the local `origin` branch, and merged into the
95d117b6
JH
31branch you are currently working on. Remote branches other than
32`master` are also added there to be tracked.
4607166d 33
6ec311da
JH
34
35OPTIONS
36-------
a2775c2a 37--local::
6ec311da
JH
38-l::
39 When the repository to clone from is on a local machine,
40 this flag bypasses normal "git aware" transport
41 mechanism and clones the repository by making a copy of
42 HEAD and everything under objects and refs directories.
43 The files under .git/objects/ directory are hardlinked
44 to save space when possible.
45
a2775c2a
EB
46--shared::
47-s::
48 When the repository to clone is on the local machine,
4607166d 49 instead of using hard links, automatically setup
23edecbc 50 .git/objects/info/alternates to share the objects
4607166d
JH
51 with the source repository. The resulting repository
52 starts out without any object of its own.
a2775c2a 53
23edecbc
SP
54--reference <repository>::
55 If the reference repository is on the local machine
56 automatically setup .git/objects/info/alternates to
57 obtain objects from the reference repository. Using
58 an already existing repository as an alternate will
59 require less objects to be copied from the repository
60 being cloned, reducing network and local storage costs.
61
a2775c2a 62--quiet::
6ec311da
JH
63-q::
64 Operate quietly. This flag is passed to "rsync" and
efc7fa53 65 "git-fetch-pack" commands when given.
6ec311da 66
a2775c2a
EB
67-n::
68 No checkout of HEAD is performed after the clone is complete.
69
87e80c4b
JH
70--bare::
71 Make a 'bare' GIT repository. That is, instead of
8a1a120c
JH
72 creating `<directory>` and placing the administrative
73 files in `<directory>/.git`, make the `<directory>`
4fb66a62
JH
74 itself the `$GIT_DIR`. This implies `-n` option. When
75 this option is used, neither the `origin` branch nor the
fb6a9f93 76 default `remotes/origin` file is created.
8a1a120c 77
e6c310fd
JS
78-o <name>::
79 Instead of using the branch name 'origin' to keep track
80 of the upstream repository, use <name> instead. Note
81 that the shorthand name stored in `remotes/origin` is
82 not affected, but the local branch name to pull the
83 remote `master` branch into is.
84
a2775c2a 85--upload-pack <upload-pack>::
6ec311da
JH
86-u <upload-pack>::
87 When given, and the repository to clone from is handled
efc7fa53 88 by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
6ec311da
JH
89 the command to specify non-default path for the command
90 run on the other end.
91
a57c8bac
JH
92--template=<template_directory>::
93 Specify the directory from which templates will be used;
94 if unset the templates are taken from the installation
95 defined default, typically `/usr/share/git-core/templates`.
96
fb6a9f93 97--use-separate-remote::
f6407823
HB
98 Save remotes heads under `$GIT_DIR/remotes/origin/` instead
99 of `$GIT_DIR/refs/heads/`. Only the master branch is saved
fb6a9f93
UKK
100 in the latter.
101
6ec311da
JH
102<repository>::
103 The (possibly remote) repository to clone from. It can
4607166d 104 be any URL git-fetch supports.
6ec311da
JH
105
106<directory>::
fb6a9f93 107 The name of a new directory to clone into. The "humanish"
0879aa28
AE
108 part of the source repository is used if no directory is
109 explicitly given ("repo" for "/path/to/repo.git" and "foo"
110 for "host.xz:foo/.git"). Cloning into an existing directory
111 is not allowed.
4607166d 112
1e2ccd3a 113Examples
2b5f3ed3 114--------
1e2ccd3a
JH
115
116Clone from upstream::
117+
118------------
119$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
120$ cd my2.6
121$ make
122------------
123
124
125Make a local clone that borrows from the current directory, without checking things out::
126+
127------------
128$ git clone -l -s -n . ../copy
129$ cd copy
130$ git show-branch
131------------
132
8a1a120c 133
23edecbc
SP
134Clone from upstream while borrowing from an existing local directory::
135+
136------------
137$ git clone --reference my2.6 \
138 git://git.kernel.org/pub/scm/.../linux-2.7 \
139 my2.7
140$ cd my2.7
141------------
142
143
87e80c4b 144Create a bare repository to publish your changes to the public::
8a1a120c
JH
145+
146------------
87e80c4b 147$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
8a1a120c
JH
148------------
149
150
151Create a repository on the kernel.org machine that borrows from Linus::
152+
153------------
87e80c4b 154$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
8a1a120c
JH
155 /pub/scm/.../me/subsys-2.6.git
156------------
157
158
6ec311da
JH
159Author
160------
161Written by Linus Torvalds <torvalds@osdl.org>
162
1e2ccd3a 163
6ec311da
JH
164Documentation
165--------------
0879aa28 166Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
6ec311da
JH
167
168
169GIT
170---
a7154e91 171Part of the gitlink:git[7] suite
6ec311da 172