Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/Documentation/git-clone.adoc # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / Documentation / git-clone.adoc` 456 lines ยท 17631 bytes Raw Blame History 1 git-clone(1) 2 ============ 3 4 NAME 5 ---- 6 git-clone - Clone a repository into a new directory 7 8 9 SYNOPSIS 10 -------- 11 [synopsis] 12 git clone [--template=] 13 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] 14 [-o ] [-b ] [-u ] [--reference ] 15 [--dissociate] [--separate-git-dir ] 16 [--depth ] [--[no-]single-branch] [--[no-]tags] 17 [--recurse-submodules[=]] [--[no-]shallow-submodules] 18 [--[no-]remote-submodules] [--jobs ] [--sparse] [--[no-]reject-shallow] 19 [--filter= [--also-filter-submodules]] [--] 20 [] 21 22 DESCRIPTION 23 ----------- 24 25 Clones a repository into a newly created directory, creates 26 remote-tracking branches for each branch in the cloned repository 27 (visible using `git branch --remotes`), and creates and checks out an 28 initial branch that is forked from the cloned repository's 29 currently active branch. 30 31 After the clone, a plain `git fetch` without arguments will update 32 all the remote-tracking branches, and a `git pull` without 33 arguments will in addition merge the remote master branch into the 34 current master branch, if any (this is untrue when `--single-branch` 35 is given; see below). 36 37 This default configuration is achieved by creating references to 38 the remote branch heads under `refs/remotes/origin` and 39 by initializing `remote.origin.url` and `remote.origin.fetch` 40 configuration variables. 41 42 43 OPTIONS 44 ------- 45 `-l`:: 46 `--local`:: 47 When the repository to clone from is on a local machine, 48 this flag bypasses the normal "Git aware" transport 49 mechanism and clones the repository by making a copy of 50 `HEAD` and everything under objects and refs directories. 51 The files under `.git/objects/` directory are hardlinked 52 to save space when possible. 53 + 54 If the repository is specified as a local path (e.g., `/path/to/repo`), 55 this is the default, and `--local` is essentially a no-op. If the 56 repository is specified as a URL, then this flag is ignored (and we 57 never use the local optimizations). Specifying `--no-local` will 58 override the default when `/path/to/repo` is given, using the regular 59 Git transport instead. 60 + 61 If the repository's `$GIT_DIR/objects` has symbolic links or is a 62 symbolic link, the clone will fail. This is a security measure to 63 prevent the unintentional copying of files by dereferencing the symbolic 64 links. 65 + 66 This option does not work with repositories owned by other users for security 67 reasons, and `--no-local` must be specified for the clone to succeed. 68 + 69 *NOTE*: this operation can race with concurrent modification to the 70 source repository, similar to running `cp -r ` while modifying 71 __. 72 73 `--no-hardlinks`:: 74 Force the cloning process from a repository on a local 75 filesystem to copy the files under the `.git/objects` 76 directory instead of using hardlinks. This may be desirable 77 if you are trying to make a back-up of your repository. 78 79 `-s`:: 80 `--shared`:: 81 When the repository to clone is on the local machine, 82 instead of using hard links, automatically setup 83 `.git/objects/info/alternates` to share the objects 84 with the source repository. The resulting repository 85 starts out without any object of its own. 86 + 87 NOTE: this is a possibly dangerous operation; do *not* use 88 it unless you understand what it does. If you clone your 89 repository using this option and then delete branches (or use any 90 other Git command that makes any existing commit unreferenced) in the 91 source repository, some objects may become unreferenced (or dangling). 92 These objects may be removed by normal Git operations (such as `git commit`) 93 which automatically call `git maintenance run --auto`. (See 94 linkgit:git-maintenance[1].) If these objects are removed and were referenced 95 by the cloned repository, then the cloned repository will become corrupt. 96 + 97 Note that running `git repack` without the `--local` option in a repository 98 cloned with `--shared` will copy objects from the source repository into a pack 99 in the cloned repository, removing the disk space savings of `clone --shared`. 100 It is safe, however, to run `git gc`, which uses the `--local` option by 101 default. 102 + 103 If you want to break the dependency of a repository cloned with `--shared` on 104 its source repository, you can simply run `git repack -a` to copy all 105 objects from the source repository into a pack in the cloned repository. 106 107 `--reference=`:: 108 `--reference-if-able=`:: 109 If the reference __ is on the local machine, 110 automatically setup `.git/objects/info/alternates` to 111 obtain objects from the reference __. Using 112 an already existing repository as an alternate will 113 require fewer objects to be copied from the repository 114 being cloned, reducing network and local storage costs. 115 When using the `--reference-if-able`, a non existing 116 directory is skipped with a warning instead of aborting 117 the clone. 118 + 119 NOTE: see the NOTE for the `--shared` option, and also the 120 `--dissociate` option. 121 122 `--dissociate`:: 123 Borrow the objects from reference repositories specified 124 with the `--reference` options only to reduce network 125 transfer, and stop borrowing from them after a clone is made 126 by making necessary local copies of borrowed objects. This 127 option can also be used when cloning locally from a 128 repository that already borrows objects from another 129 repository--the new repository will borrow objects from the 130 same repository, and this option can be used to stop the 131 borrowing. 132 133 `-q`:: 134 `--quiet`:: 135 Operate quietly. Progress is not reported to the standard 136 error stream. 137 138 `-v`:: 139 `--verbose`:: 140 Run verbosely. Does not affect the reporting of progress status 141 to the standard error stream. 142 143 `--progress`:: 144 Report progress status on the standard error stream 145 by default when attached to a terminal, unless `--quiet` 146 is specified. This flag forces progress status even if the 147 standard error stream is not directed to a terminal. 148 149 `--server-option=