6 git-clone - Clones a repository
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>
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
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.
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.
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.
65 Operate quietly. This flag is passed to "rsync" and
66 "git-fetch-pack" commands when given.
69 No checkout of HEAD is performed after the clone is complete.
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.
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>::
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
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
116 The (possibly remote) repository to clone from. It can
117 be any URL git-fetch supports.
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
129 Clone from upstream::
132 $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
138 Make a local clone that borrows from the current directory, without checking things out::
141 $ git clone -l -s -n . ../copy
147 Clone from upstream while borrowing from an existing local directory::
150 $ git clone --reference my2.6 \
151 git://git.kernel.org/pub/scm/.../linux-2.7 \
157 Create a bare repository to publish your changes to the public::
160 $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
164 Create a repository on the kernel.org machine that borrows from Linus::
167 $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
168 /pub/scm/.../me/subsys-2.6.git
174 Written by Linus Torvalds <torvalds@osdl.org>
179 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
184 Part of the gitlink:git[7] suite