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