Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | git-clone(1) |
| 2 | ============ |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 7c73c66 | 2007-01-19 00:37:50 | [diff] [blame] | 6 | git-clone - Clones a repository into a new directory |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 11 | [verse] |
Junio C Hamano | f31d9f5 | 2006-05-28 20:58:09 | [diff] [blame] | 12 | 'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare] |
| 13 | [-o <name>] [-u <upload-pack>] [--reference <repository>] |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 14 | [--depth <depth>] <repository> [<directory>] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 15 | |
| 16 | DESCRIPTION |
| 17 | ----------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 18 | |
Junio C Hamano | 5102d9a | 2006-12-08 07:23:46 | [diff] [blame] | 19 | Clones a repository into a newly created directory, creates |
| 20 | remote-tracking branches for each branch in the cloned repository |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 21 | (visible using `git branch -r`), and creates and checks out an initial |
| 22 | branch equal to the cloned repository's currently active branch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 23 | |
Junio C Hamano | 5102d9a | 2006-12-08 07:23:46 | [diff] [blame] | 24 | After the clone, a plain `git fetch` without arguments will update |
| 25 | all the remote-tracking branches, and a `git pull` without |
| 26 | arguments will in addition merge the remote master branch into the |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 27 | current master branch, if any. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 28 | |
Junio C Hamano | 5102d9a | 2006-12-08 07:23:46 | [diff] [blame] | 29 | This default configuration is achieved by creating references to |
| 30 | the remote branch heads under `$GIT_DIR/refs/remotes/origin` and |
| 31 | by initializing `remote.origin.url` and `remote.origin.fetch` |
| 32 | configuration variables. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 33 | |
Junio C Hamano | b288d9e | 2007-01-02 00:04:15 | [diff] [blame] | 34 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 35 | OPTIONS |
| 36 | ------- |
| 37 | --local:: |
| 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 | |
| 46 | --shared:: |
| 47 | -s:: |
| 48 | When the repository to clone is on the local machine, |
| 49 | instead of using hard links, automatically setup |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 50 | .git/objects/info/alternates to share the objects |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 51 | with the source repository. The resulting repository |
| 52 | starts out without any object of its own. |
| 53 | |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 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 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 62 | --quiet:: |
| 63 | -q:: |
| 64 | Operate quietly. This flag is passed to "rsync" and |
Junio C Hamano | 97f518c | 2006-06-22 19:49:35 | [diff] [blame] | 65 | "git-fetch-pack" commands when given. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 66 | |
| 67 | -n:: |
| 68 | No checkout of HEAD is performed after the clone is complete. |
| 69 | |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 70 | --bare:: |
| 71 | Make a 'bare' GIT repository. That is, instead of |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 72 | creating `<directory>` and placing the administrative |
| 73 | files in `<directory>/.git`, make the `<directory>` |
Junio C Hamano | 9f292e7 | 2006-11-24 11:37:29 | [diff] [blame] | 74 | itself the `$GIT_DIR`. This obviously implies the `-n` |
| 75 | because there is nowhere to check out the working tree. |
| 76 | Also the branch heads at the remote are copied directly |
| 77 | to corresponding local branch heads, without mapping |
| 78 | them to `refs/remotes/origin/`. When this option is |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 79 | used, neither remote-tracking branches nor the related |
| 80 | configuration variables are created. |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 81 | |
Junio C Hamano | dcc22ee | 2006-11-03 02:40:13 | [diff] [blame] | 82 | --origin <name>:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 83 | -o <name>:: |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 84 | Instead of using the remote name 'origin' to keep track |
| 85 | of the upstream repository, use <name> instead. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 86 | |
| 87 | --upload-pack <upload-pack>:: |
| 88 | -u <upload-pack>:: |
| 89 | When given, and the repository to clone from is handled |
Junio C Hamano | 97f518c | 2006-06-22 19:49:35 | [diff] [blame] | 90 | by 'git-fetch-pack', '--exec=<upload-pack>' is passed to |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 91 | the command to specify non-default path for the command |
| 92 | run on the other end. |
| 93 | |
Junio C Hamano | f31d9f5 | 2006-05-28 20:58:09 | [diff] [blame] | 94 | --template=<template_directory>:: |
| 95 | Specify the directory from which templates will be used; |
| 96 | if unset the templates are taken from the installation |
| 97 | defined default, typically `/usr/share/git-core/templates`. |
| 98 | |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 99 | --depth <depth>:: |
Junio C Hamano | b288d9e | 2007-01-02 00:04:15 | [diff] [blame] | 100 | Create a 'shallow' clone with a history truncated to the |
| 101 | specified number of revs. A shallow repository has |
| 102 | number of limitations (you cannot clone or fetch from |
| 103 | it, nor push from nor into it), but is adequate if you |
| 104 | want to only look at near the tip of a large project |
| 105 | with a long history, and would want to send in a fixes |
| 106 | as patches. |
| 107 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 108 | <repository>:: |
| 109 | The (possibly remote) repository to clone from. It can |
| 110 | be any URL git-fetch supports. |
| 111 | |
| 112 | <directory>:: |
Junio C Hamano | 8db10ef | 2006-06-09 04:31:57 | [diff] [blame] | 113 | The name of a new directory to clone into. The "humanish" |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 114 | part of the source repository is used if no directory is |
| 115 | explicitly given ("repo" for "/path/to/repo.git" and "foo" |
| 116 | for "host.xz:foo/.git"). Cloning into an existing directory |
| 117 | is not allowed. |
| 118 | |
| 119 | Examples |
Junio C Hamano | 1bb569e | 2006-05-05 23:14:25 | [diff] [blame] | 120 | -------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 121 | |
| 122 | Clone from upstream:: |
| 123 | + |
| 124 | ------------ |
| 125 | $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6 |
| 126 | $ cd my2.6 |
| 127 | $ make |
| 128 | ------------ |
| 129 | |
| 130 | |
| 131 | Make a local clone that borrows from the current directory, without checking things out:: |
| 132 | + |
| 133 | ------------ |
| 134 | $ git clone -l -s -n . ../copy |
| 135 | $ cd copy |
| 136 | $ git show-branch |
| 137 | ------------ |
| 138 | |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 139 | |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 140 | Clone from upstream while borrowing from an existing local directory:: |
| 141 | + |
| 142 | ------------ |
| 143 | $ git clone --reference my2.6 \ |
| 144 | git://git.kernel.org/pub/scm/.../linux-2.7 \ |
| 145 | my2.7 |
| 146 | $ cd my2.7 |
| 147 | ------------ |
| 148 | |
| 149 | |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 150 | Create a bare repository to publish your changes to the public:: |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 151 | + |
| 152 | ------------ |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 153 | $ git clone --bare -l /home/proj/.git /pub/scm/proj.git |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 154 | ------------ |
| 155 | |
| 156 | |
| 157 | Create a repository on the kernel.org machine that borrows from Linus:: |
| 158 | + |
| 159 | ------------ |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 160 | $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \ |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 161 | /pub/scm/.../me/subsys-2.6.git |
| 162 | ------------ |
| 163 | |
| 164 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 165 | Author |
| 166 | ------ |
| 167 | Written by Linus Torvalds <torvalds@osdl.org> |
| 168 | |
| 169 | |
| 170 | Documentation |
| 171 | -------------- |
| 172 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. |
| 173 | |
| 174 | |
| 175 | GIT |
| 176 | --- |
| 177 | Part of the gitlink:git[7] suite |
| 178 | |