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-push.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-push.adoc` 811 lines · 32257 bytes Raw Blame History 1 git-push(1) 2 =========== 3 4 NAME 5 ---- 6 git-push - Update remote refs along with associated objects 7 8 9 SYNOPSIS 10 -------- 11 [synopsis] 12 git push [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=] 13 [--repo=] [-f | --force] [-d | --delete] [--prune] [-q | --quiet] [-v | --verbose] 14 [-u | --set-upstream] [-o | --push-option=] 15 [--[no-]signed | --signed=(true|false|if-asked)] 16 [--force-with-lease[=[:]] [--force-if-includes]] 17 [--no-verify] [ [...]] 18 19 DESCRIPTION 20 ----------- 21 Updates one or more branches, tags, or other references in one or more 22 remote repositories from your local repository, and sends all necessary 23 data that isn't already on the remote. 24 25 The simplest way to push is `git push `. 26 `git push origin main` will push the local `main` branch to the `main` 27 branch on the remote named `origin`. 28 29 You can also push to multiple remotes at once by using a remote group. 30 A remote group is a named list of remotes configured via `remotes.` 31 in your git config: 32 33 $ git config remotes.all-remotes "origin gitlab backup" 34 35 Then `git push all-remotes` will push to `origin`, `gitlab`, and 36 `backup` in turn, as if you had run `git push` against each one 37 individually. Each remote is pushed independently using its own 38 push mapping configuration. There is a `remotes.` entry in 39 the configuration file. (See linkgit:git-config[1]). 40 41 The `` argument defaults to the upstream for the current 42 branch, or `origin` if there's no configured upstream. 43 44 To decide which branches, tags, or other refs to push, Git uses 45 (in order of precedence): 46 47 1. The `` argument(s) (for example `main` in `git push origin main`) 48 or the `--all`, `--mirror`, or `--tags` options 49 2. The `remote..push` configuration for the repository being pushed to 50 3. The `push.default` configuration. The default is `push.default=simple`, 51 which will push to a branch with the same name as the current branch. 52 See the <> section below for more on `push.default`. 53 54 `git push` may fail if you haven't set an upstream for the current branch, 55 depending on what `push.default` is set to. 56 See the <> section below for more 57 on how to set and use upstreams. 58 59 You can make interesting things happen to a repository 60 every time you push into it, by setting up 'hooks' there. See 61 documentation for linkgit:git-receive-pack[1]. 62 63 [[OPTIONS]] 64 OPTIONS 65 ------- 66 __:: 67 The "remote" repository that is the destination of a push 68 operation. This parameter can be either a URL 69 (see the section <> below), the name 70 of a remote (see the section <> below), 71 or the name of a remote group 72 (see the section <> below). 73 74 `...`:: 75 Specify what destination ref to update with what source object. 76 + 77 The format for a refspec is `[+][:]`, for example `main`, 78 `main:other`, or `HEAD^:refs/heads/main`. 79 + 80 The __ is often the name of the local branch to push, but it can be 81 any arbitrary "SHA-1 expression" (see linkgit:gitrevisions[7]). 82 + 83 The __ determines what ref to update on the remote side. It must be the 84 name of a branch, tag, or other ref, not an arbitrary expression. 85 + 86 The `+` is optional and does the same thing as `--force`. 87 + 88 You can write a refspec using the fully expanded form (for 89 example `refs/heads/main:refs/heads/main`) which specifies the exact source 90 and destination, or with a shorter form (for example `main` or 91 `main:other`). Here are the rules for how refspecs are expanded, 92 as well as various other special refspec forms: 93 + 94 * __ without a `:` means to update the same ref as the 95 __, unless the `remote..push` configuration specifies a 96 different __. For example, if `main` is a branch, then the refspec 97 `main` expands to `main:refs/heads/main`. 98 * If __ unambiguously refers to a ref on the remote, 99 then expand it to that ref. For example, if `v1.0` is a tag on the 100 remote, then `HEAD:v1.0` expands to `HEAD:refs/tags/v1.0`. 101 * If __ resolves to a ref starting with `refs/heads/` or `refs/tags/`, 102 then prepend that to . For example, if `main` is a branch, then 103 `main:other` expands to `main:refs/heads/other` 104 * The special refspec `:` (or `+:` to allow non-fast-forward updates) 105 directs Git to push "matching" branches: for every branch that exists on 106 the local side, the remote side is updated if a branch of the same name 107 already exists on the remote side. 108 * __ may contain a `*` to indicate a simple pattern match. 109 This works like a glob that matches any ref matching the pattern. 110 There must be only one `*` in both the `` and ``. 111 It will map refs to the destination by replacing the * with the 112 contents matched from the source. For example, `refs/heads/*:refs/heads/*` 113 will push all branches. 114 * A refspec starting with `^` is a negative refspec. 115 This specifies refs to exclude. A ref will be considered to 116 match if it matches at least one positive refspec, and does not 117 match any negative refspec. Negative refspecs can be pattern refspecs. 118 They must only contain a __. 119 Fully spelled out hex object names are also not supported. 120 For example, `git push origin 'refs/heads/*' '^refs/heads/dev-*'` 121 will push all branches except for those starting with `dev-` 122 * If __ is empty, it deletes the __ ref from the remote 123 repository. For example, `git push origin :dev` will 124 delete the `dev` branch. 125 * `tag ` expands to `refs/tags/:refs/tags/`. 126 This is technically a special syntax for `git push` and not a refspec, 127 since in `git push origin tag v1.0` the arguments `tag` and `v1.0` 128 are separate. 129 * If the refspec can't be expanded unambiguously, error out 130 with an error indicating what was tried, and depending 131 on the `advice.pushUnqualifiedRefname` configuration (see 132 linkgit:git-config[1]) suggest what refs/ namespace you may have 133 wanted to push to. 134 135 Not all updates are allowed: see 136 <> below for the details. 137 138 `--all`:: 139 `--branches`:: 140 Push all branches (i.e. refs under `refs/heads/`); cannot be 141 used with other . 142 143 `--prune`:: 144 Remove remote branches that don't have a local counterpart. For example 145 a remote branch `tmp` will be removed if a local branch with the same 146 name doesn't exist any more. This also respects refspecs, e.g. 147 `git push --prune remote refs/heads/*:refs/tmp/*` would 148 make sure that remote `refs/tmp/foo` will be removed if `refs/heads/foo` 149 doesn't exist. 150 151 `--mirror`:: 152 Instead of naming each ref to push, specifies that all 153 refs under `refs/` (which includes but is not 154 limited to `refs/heads/`, `refs/remotes/`, and `refs/tags/`) 155 be mirrored to the remote repository. Newly created local 156 refs will be pushed to the remote end, locally updated refs 157 will be force updated on the remote end, and deleted refs 158 will be removed from the remote end. This is the default 159 if the configuration option `remote..mirror` is 160 set. 161 162 `-n`:: 163 `--dry-run`:: 164 Do everything except actually send the updates. 165 166 `--porcelain`:: 167 Produce machine-readable output. The output status line for each ref 168 will be tab-separated and sent to stdout instead of stderr. The full 169 symbolic names of the refs will be given. 170 171 `-d`:: 172 `--delete`:: 173 All listed refs are deleted from the remote repository. This is 174 the same as prefixing all refs with a colon. 175 176 `--tags`:: 177 All refs under `refs/tags` are pushed, in 178 addition to refspecs explicitly listed on the command 179 line. 180 181 `--follow-tags`:: 182 Push all the refs that would be pushed without this option, 183 and also push annotated tags in `refs/tags` that are missing 184 from the remote but are pointing at commit-ish that are 185 reachable from the refs being pushed. This can also be specified 186 with configuration variable `push.followTags`. For more 187 information, see `push.followTags` in linkgit:git-config[1]. 188 189 `--signed`:: 190 `--no-signed`:: 191 `--signed=(true|false|if-asked)`:: 192 GPG-sign the push request to update refs on the receiving 193 side, to allow it to be checked by the hooks and/or be 194 logged. Possible values are: 195 `false`;; 196 `--no-signed`;; 197 no signing will be attempted. 198 `true`;; 199 `--signed`;; 200 the push will fail if the server does not support signed pushes. 201 `if-asked`;; 202 sign if and only if the server supports signed pushes. The push 203 will also fail if the actual call to `gpg --sign` fails. See 204 linkgit:git-receive-pack[1] for the details on the receiving end. 205 206 `--atomic`:: 207 `--no-atomic`:: 208 Use an atomic transaction on the remote side if available. 209 Either all refs are updated, or on error, no refs are updated. 210 If the server does not support atomic pushes the push will fail. 211 212 `-o