{
    "mode": "info",
    "parameter": "git-push",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/git-push/json",
    "generated": "2026-07-11T05:50:41Z",
    "synopsis": "git push [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]\n[--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]\n[-u | --set-upstream] [-o <string> | --push-option=<string>]\n[--[no-]signed|--signed=(true|false|if-asked)]\n[--force-with-lease[=<refname>[:<expect>]] [--force-if-includes]]\n[--no-verify] [<repository> [<refspec>...]]",
    "sections": {
        "NAME": {
            "content": "git-push - Update remote refs along with associated objects\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git push [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]\n[--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]\n[-u | --set-upstream] [-o <string> | --push-option=<string>]\n[--[no-]signed|--signed=(true|false|if-asked)]\n[--force-with-lease[=<refname>[:<expect>]] [--force-if-includes]]\n[--no-verify] [<repository> [<refspec>...]]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Updates remote refs using local refs, while sending objects necessary\nto complete the given refs.\n\nYou can make interesting things happen to a repository every time you\npush into it, by setting up hooks there. See documentation for git-\nreceive-pack(1).\n\nWhen the command line does not specify where to push with the\n<repository> argument, branch.*.remote configuration for the current\nbranch is consulted to determine where to push. If the configuration is\nmissing, it defaults to origin.\n\nWhen the command line does not specify what to push with <refspec>...\narguments or --all, --mirror, --tags options, the command finds the\ndefault <refspec> by consulting remote.*.push configuration, and if it\nis not found, honors push.default configuration to decide what to push\n(See git-config(1) for the meaning of push.default).\n\nWhen neither the command-line nor the configuration specify what to\npush, the default behavior is used, which corresponds to the simple\nvalue for push.default: the current branch is pushed to the\ncorresponding upstream branch, but as a safety measure, the push is\naborted if the upstream branch does not have the same name as the local\none.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "<repository>\nThe \"remote\" repository that is destination of a push operation.\nThis parameter can be either a URL (see the section GIT URLS below)\nor the name of a remote (see the section REMOTES below).\n\n<refspec>...\nSpecify what destination ref to update with what source object. The\nformat of a <refspec> parameter is an optional plus +, followed by\nthe source object <src>, followed by a colon :, followed by the\ndestination ref <dst>.\n\nThe <src> is often the name of the branch you would want to push,\nbut it can be any arbitrary \"SHA-1 expression\", such as master~4 or\nHEAD (see gitrevisions(7)).\n\nThe <dst> tells which ref on the remote side is updated with this\npush. Arbitrary expressions cannot be used here, an actual ref must\nbe named. If git push [<repository>] without any <refspec> argument\nis set to update some ref at the destination with <src> with\nremote.<repository>.push configuration variable, :<dst> part can be\nomitted--such a push will update a ref that <src> normally updates\nwithout any <refspec> on the command line. Otherwise, missing\n:<dst> means to update the same ref as the <src>.\n\nIf <dst> doesn't start with refs/ (e.g.  refs/heads/master) we will\ntry to infer where in refs/* on the destination <repository> it\nbelongs based on the type of <src> being pushed and whether <dst>\nis ambiguous.\n\no   If <dst> unambiguously refers to a ref on the <repository>\nremote, then push to that ref.\n\no   If <src> resolves to a ref starting with refs/heads/ or\nrefs/tags/, then prepend that to <dst>.\n\no   Other ambiguity resolutions might be added in the future, but\nfor now any other cases will error out with an error indicating\nwhat we tried, and depending on the\nadvice.pushUnqualifiedRefname configuration (see git-config(1))\nsuggest what refs/ namespace you may have wanted to push to.\n\nThe object referenced by <src> is used to update the <dst>\nreference on the remote side. Whether this is allowed depends on\nwhere in refs/* the <dst> reference lives as described in detail\nbelow, in those sections \"update\" means any modifications except\ndeletes, which as noted after the next few sections are treated\ndifferently.\n\nThe refs/heads/* namespace will only accept commit objects, and\nupdates only if they can be fast-forwarded.\n\nThe refs/tags/* namespace will accept any kind of object (as\ncommits, trees and blobs can be tagged), and any updates to them\nwill be rejected.\n\nIt's possible to push any type of object to any namespace outside\nof refs/{tags,heads}/*. In the case of tags and commits, these will\nbe treated as if they were the commits inside refs/heads/* for the\npurposes of whether the update is allowed.\n\nI.e. a fast-forward of commits and tags outside refs/{tags,heads}/*\nis allowed, even in cases where what's being fast-forwarded is not\na commit, but a tag object which happens to point to a new commit\nwhich is a fast-forward of the commit the last tag (or commit) it's\nreplacing. Replacing a tag with an entirely different tag is also\nallowed, if it points to the same commit, as well as pushing a\npeeled tag, i.e. pushing the commit that existing tag object points\nto, or a new tag object which an existing commit points to.\n\nTree and blob objects outside of refs/{tags,heads}/* will be\ntreated the same way as if they were inside refs/tags/*, any update\nof them will be rejected.\n\nAll of the rules described above about what's not allowed as an\nupdate can be overridden by adding an the optional leading + to a\nrefspec (or using --force command line option). The only exception\nto this is that no amount of forcing will make the refs/heads/*\nnamespace accept a non-commit object. Hooks and configuration can\nalso override or amend these rules, see e.g.\nreceive.denyNonFastForwards in git-config(1) and pre-receive and\nupdate in githooks(5).\n\nPushing an empty <src> allows you to delete the <dst> ref from the\nremote repository. Deletions are always accepted without a leading\n+ in the refspec (or --force), except when forbidden by\nconfiguration or hooks. See receive.denyDeletes in git-config(1)\nand pre-receive and update in githooks(5).\n\nThe special refspec : (or +: to allow non-fast-forward updates)\ndirects Git to push \"matching\" branches: for every branch that\nexists on the local side, the remote side is updated if a branch of\nthe same name already exists on the remote side.\n\ntag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.\n",
            "subsections": [
                {
                    "name": "--all",
                    "content": "Push all branches (i.e. refs under refs/heads/); cannot be used\nwith other <refspec>.\n",
                    "long": "--all"
                },
                {
                    "name": "--prune",
                    "content": "Remove remote branches that don't have a local counterpart. For\nexample a remote branch tmp will be removed if a local branch with\nthe same name doesn't exist any more. This also respects refspecs,\ne.g.  git push --prune remote refs/heads/*:refs/tmp/* would make\nsure that remote refs/tmp/foo will be removed if refs/heads/foo\ndoesn't exist.\n",
                    "long": "--prune"
                },
                {
                    "name": "--mirror",
                    "content": "Instead of naming each ref to push, specifies that all refs under\nrefs/ (which includes but is not limited to refs/heads/,\nrefs/remotes/, and refs/tags/) be mirrored to the remote\nrepository. Newly created local refs will be pushed to the remote\nend, locally updated refs will be force updated on the remote end,\nand deleted refs will be removed from the remote end. This is the\ndefault if the configuration option remote.<remote>.mirror is set.\n",
                    "long": "--mirror"
                },
                {
                    "name": "-n, --dry-run",
                    "content": "Do everything except actually send the updates.\n",
                    "flag": "-n",
                    "long": "--dry-run"
                },
                {
                    "name": "--porcelain",
                    "content": "Produce machine-readable output. The output status line for each\nref will be tab-separated and sent to stdout instead of stderr. The\nfull symbolic names of the refs will be given.\n",
                    "long": "--porcelain"
                },
                {
                    "name": "-d, --delete",
                    "content": "All listed refs are deleted from the remote repository. This is the\nsame as prefixing all refs with a colon.\n",
                    "flag": "-d",
                    "long": "--delete"
                },
                {
                    "name": "--tags",
                    "content": "All refs under refs/tags are pushed, in addition to refspecs\nexplicitly listed on the command line.\n",
                    "long": "--tags"
                },
                {
                    "name": "--follow-tags",
                    "content": "Push all the refs that would be pushed without this option, and\nalso push annotated tags in refs/tags that are missing from the\nremote but are pointing at commit-ish that are reachable from the\nrefs being pushed. This can also be specified with configuration\nvariable push.followTags. For more information, see push.followTags\nin git-config(1).\n\n--[no-]signed, --signed=(true|false|if-asked)\nGPG-sign the push request to update refs on the receiving side, to\nallow it to be checked by the hooks and/or be logged. If false or\n--no-signed, no signing will be attempted. If true or --signed, the\npush will fail if the server does not support signed pushes. If set\nto if-asked, sign if and only if the server supports signed pushes.\nThe push will also fail if the actual call to gpg --sign fails. See\ngit-receive-pack(1) for the details on the receiving end.\n\n--[no-]atomic\nUse an atomic transaction on the remote side if available. Either\nall refs are updated, or on error, no refs are updated. If the\nserver does not support atomic pushes the push will fail.\n\n-o <option>, --push-option=<option>\nTransmit the given string to the server, which passes them to the\npre-receive as well as the post-receive hook. The given string must\nnot contain a NUL or LF character. When multiple\n--push-option=<option> are given, they are all sent to the other\nside in the order listed on the command line. When no\n--push-option=<option> is given from the command line, the values\nof configuration variable push.pushOption are used instead.\n\n--receive-pack=<git-receive-pack>, --exec=<git-receive-pack>\nPath to the git-receive-pack program on the remote end. Sometimes\nuseful when pushing to a remote repository over ssh, and you do not\nhave the program in a directory on the default $PATH.\n\n--[no-]force-with-lease, --force-with-lease=<refname>,\n--force-with-lease=<refname>:<expect>\nUsually, \"git push\" refuses to update a remote ref that is not an\nancestor of the local ref used to overwrite it.\n\nThis option overrides this restriction if the current value of the\nremote ref is the expected value. \"git push\" fails otherwise.\n\nImagine that you have to rebase what you have already published.\nYou will have to bypass the \"must fast-forward\" rule in order to\nreplace the history you originally published with the rebased\nhistory. If somebody else built on top of your original history\nwhile you are rebasing, the tip of the branch at the remote may\nadvance with their commit, and blindly pushing with --force will\nlose their work.\n\nThis option allows you to say that you expect the history you are\nupdating is what you rebased and want to replace. If the remote ref\nstill points at the commit you specified, you can be sure that no\nother people did anything to the ref. It is like taking a \"lease\"\non the ref without explicitly locking it, and the remote ref is\nupdated only if the \"lease\" is still valid.\n\n--force-with-lease alone, without specifying the details, will\nprotect all remote refs that are going to be updated by requiring\ntheir current value to be the same as the remote-tracking branch we\nhave for them.\n\n--force-with-lease=<refname>, without specifying the expected\nvalue, will protect the named ref (alone), if it is going to be\nupdated, by requiring its current value to be the same as the\nremote-tracking branch we have for it.\n\n--force-with-lease=<refname>:<expect> will protect the named ref\n(alone), if it is going to be updated, by requiring its current\nvalue to be the same as the specified value <expect> (which is\nallowed to be different from the remote-tracking branch we have for\nthe refname, or we do not even have to have such a remote-tracking\nbranch when this form is used). If <expect> is the empty string,\nthen the named ref must not already exist.\n\nNote that all forms other than\n--force-with-lease=<refname>:<expect> that specifies the expected\ncurrent value of the ref explicitly are still experimental and\ntheir semantics may change as we gain experience with this feature.\n\n\"--no-force-with-lease\" will cancel all the previous\n--force-with-lease on the command line.\n\nA general note on safety: supplying this option without an expected\nvalue, i.e. as --force-with-lease or --force-with-lease=<refname>\ninteracts very badly with anything that implicitly runs git fetch\non the remote to be pushed to in the background, e.g.  git fetch\norigin on your repository in a cronjob.\n\nThe protection it offers over --force is ensuring that subsequent\nchanges your work wasn't based on aren't clobbered, but this is\ntrivially defeated if some background process is updating refs in\nthe background. We don't have anything except the remote tracking\ninfo to go by as a heuristic for refs you're expected to have seen\n& are willing to clobber.\n\nIf your editor or some other system is running git fetch in the\nbackground for you a way to mitigate this is to simply set up\nanother remote:\n\ngit remote add origin-push $(git config remote.origin.url)\ngit fetch origin-push\n\nNow when the background process runs git fetch origin the\nreferences on origin-push won't be updated, and thus commands like:\n\ngit push --force-with-lease origin-push\n\nWill fail unless you manually run git fetch origin-push. This\nmethod is of course entirely defeated by something that runs git\nfetch --all, in that case you'd need to either disable it or do\nsomething more tedious like:\n\ngit fetch              # update 'master' from remote\ngit tag base master    # mark our base point\ngit rebase -i master   # rewrite some commits\ngit push --force-with-lease=master:base master:master\n\nI.e. create a base tag for versions of the upstream code that\nyou've seen and are willing to overwrite, then rewrite history, and\nfinally force push changes to master if the remote version is still\nat base, regardless of what your local remotes/origin/master has\nbeen updated to in the background.\n\nAlternatively, specifying --force-if-includes as an ancillary\noption along with --force-with-lease[=<refname>] (i.e., without\nsaying what exact commit the ref on the remote side must be\npointing at, or which refs on the remote side are being protected)\nat the time of \"push\" will verify if updates from the\nremote-tracking refs that may have been implicitly updated in the\nbackground are integrated locally before allowing a forced update.\n",
                    "long": "--follow-tags"
                },
                {
                    "name": "-f, --force",
                    "content": "Usually, the command refuses to update a remote ref that is not an\nancestor of the local ref used to overwrite it. Also, when\n--force-with-lease option is used, the command refuses to update a\nremote ref whose current value does not match what is expected.\n\nThis flag disables these checks, and can cause the remote\nrepository to lose commits; use it with care.\n\nNote that --force applies to all the refs that are pushed, hence\nusing it with push.default set to matching or with multiple push\ndestinations configured with remote.*.push may overwrite refs other\nthan the current branch (including local refs that are strictly\nbehind their remote counterpart). To force a push to only one\nbranch, use a + in front of the refspec to push (e.g git push\norigin +master to force a push to the master branch). See the\n<refspec>...  section above for details.\n\n--[no-]force-if-includes\nForce an update only if the tip of the remote-tracking ref has been\nintegrated locally.\n\nThis option enables a check that verifies if the tip of the\nremote-tracking ref is reachable from one of the \"reflog\" entries\nof the local branch based in it for a rewrite. The check ensures\nthat any updates from the remote have been incorporated locally by\nrejecting the forced update if that is not the case.\n\nIf the option is passed without specifying --force-with-lease, or\nspecified along with --force-with-lease=<refname>:<expect>, it is a\n\"no-op\".\n\nSpecifying --no-force-if-includes disables this behavior.\n\n--repo=<repository>\nThis option is equivalent to the <repository> argument. If both are\nspecified, the command-line argument takes precedence.\n",
                    "flag": "-f",
                    "long": "--force"
                },
                {
                    "name": "-u, --set-upstream",
                    "content": "For every branch that is up to date or successfully pushed, add\nupstream (tracking) reference, used by argument-less git-pull(1)\nand other commands. For more information, see branch.<name>.merge\nin git-config(1).\n\n--[no-]thin\nThese options are passed to git-send-pack(1). A thin transfer\nsignificantly reduces the amount of sent data when the sender and\nreceiver share many of the same objects in common. The default is\n--thin.\n",
                    "flag": "-u",
                    "long": "--set-upstream"
                },
                {
                    "name": "-q, --quiet",
                    "content": "Suppress all output, including the listing of updated refs, unless\nan error occurs. Progress is not reported to the standard error\nstream.\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "-v, --verbose",
                    "content": "Run verbosely.\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "--progress",
                    "content": "Progress status is reported on the standard error stream by default\nwhen it is attached to a terminal, unless -q is specified. This\nflag forces progress status even if the standard error stream is\nnot directed to a terminal.\n\n--no-recurse-submodules, --recurse-submodules=check|on-demand|only|no\nMay be used to make sure all submodule commits used by the\nrevisions to be pushed are available on a remote-tracking branch.\nIf check is used Git will verify that all submodule commits that\nchanged in the revisions to be pushed are available on at least one\nremote of the submodule. If any commits are missing the push will\nbe aborted and exit with non-zero status. If on-demand is used all\nsubmodules that changed in the revisions to be pushed will be\npushed. If on-demand was not able to push all necessary revisions\nit will also be aborted and exit with non-zero status. If only is\nused all submodules will be recursively pushed while the\nsuperproject is left unpushed. A value of no or using\n--no-recurse-submodules can be used to override the\npush.recurseSubmodules configuration variable when no submodule\nrecursion is required.\n\n--[no-]verify\nToggle the pre-push hook (see githooks(5)). The default is\n--verify, giving the hook a chance to prevent the push. With\n--no-verify, the hook is bypassed completely.\n\n-4, --ipv4\nUse IPv4 addresses only, ignoring IPv6 addresses.\n\n-6, --ipv6\nUse IPv6 addresses only, ignoring IPv4 addresses.\n",
                    "long": "--progress"
                }
            ]
        },
        "GIT URLS": {
            "content": "In general, URLs contain information about the transport protocol, the\naddress of the remote server, and the path to the repository. Depending\non the transport protocol, some of this information may be absent.\n\nGit supports ssh, git, http, and https protocols (in addition, ftp, and\nftps can be used for fetching, but this is inefficient and deprecated;\ndo not use it).\n\nThe native transport (i.e. git:// URL) does no authentication and\nshould be used with caution on unsecured networks.\n\nThe following syntaxes may be used with them:\n\no   ssh://[user@]host.xz[:port]/path/to/repo.git/\n\no   git://host.xz[:port]/path/to/repo.git/\n\no   http[s]://host.xz[:port]/path/to/repo.git/\n\no   ftp[s]://host.xz[:port]/path/to/repo.git/\n\nAn alternative scp-like syntax may also be used with the ssh protocol:\n\no   [user@]host.xz:path/to/repo.git/\n\nThis syntax is only recognized if there are no slashes before the first\ncolon. This helps differentiate a local path that contains a colon. For\nexample the local path foo:bar could be specified as an absolute path\nor ./foo:bar to avoid being misinterpreted as an ssh url.\n\nThe ssh and git protocols additionally support ~username expansion:\n\no   ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/\n\no   git://host.xz[:port]/~[user]/path/to/repo.git/\n\no   [user@]host.xz:/~[user]/path/to/repo.git/\n\nFor local repositories, also supported by Git natively, the following\nsyntaxes may be used:\n\no   /path/to/repo.git/\n\no   file:///path/to/repo.git/\n\nThese two syntaxes are mostly equivalent, except when cloning, when the\nformer implies --local option. See git-clone(1) for details.\n\ngit clone, git fetch and git pull, but not git push, will also accept a\nsuitable bundle file. See git-bundle(1).\n\nWhen Git doesn't know how to handle a certain transport protocol, it\nattempts to use the remote-<transport> remote helper, if one exists. To\nexplicitly request a remote helper, the following syntax may be used:\n\no   <transport>::<address>\n\nwhere <address> may be a path, a server and path, or an arbitrary\nURL-like string recognized by the specific remote helper being invoked.\nSee gitremote-helpers(7) for details.\n\nIf there are a large number of similarly-named remote repositories and\nyou want to use a different format for them (such that the URLs you use\nwill be rewritten into URLs that work), you can create a configuration\nsection of the form:\n\n[url \"<actual url base>\"]\ninsteadOf = <other url base>\n\nFor example, with this:\n\n[url \"git://git.host.xz/\"]\ninsteadOf = host.xz:/path/to/\ninsteadOf = work:\n\na URL like \"work:repo.git\" or like \"host.xz:/path/to/repo.git\" will be\nrewritten in any context that takes a URL to be\n\"git://git.host.xz/repo.git\".\n\nIf you want to rewrite URLs for push only, you can create a\nconfiguration section of the form:\n\n[url \"<actual url base>\"]\npushInsteadOf = <other url base>\n\nFor example, with this:\n\n[url \"ssh://example.org/\"]\npushInsteadOf = git://example.org/\n\na URL like \"git://example.org/path/to/repo.git\" will be rewritten to\n\"ssh://example.org/path/to/repo.git\" for pushes, but pulls will still\nuse the original URL.\n",
            "subsections": []
        },
        "REMOTES": {
            "content": "The name of one of the following can be used instead of a URL as\n<repository> argument:\n\no   a remote in the Git configuration file: $GITDIR/config,\n\no   a file in the $GITDIR/remotes directory, or\n\no   a file in the $GITDIR/branches directory.\n\nAll of these also allow you to omit the refspec from the command line\nbecause they each contain a refspec which git will use by default.\n\nNamed remote in configuration file\nYou can choose to provide the name of a remote which you had previously\nconfigured using git-remote(1), git-config(1) or even by a manual edit\nto the $GITDIR/config file. The URL of this remote will be used to\naccess the repository. The refspec of this remote will be used by\ndefault when you do not provide a refspec on the command line. The\nentry in the config file would appear like this:\n\n[remote \"<name>\"]\nurl = <url>\npushurl = <pushurl>\npush = <refspec>\nfetch = <refspec>\n\nThe <pushurl> is used for pushes only. It is optional and defaults to\n<url>.\n\nNamed file in $GITDIR/remotes\nYou can choose to provide the name of a file in $GITDIR/remotes. The\nURL in this file will be used to access the repository. The refspec in\nthis file will be used as default when you do not provide a refspec on\nthe command line. This file should have the following format:\n\nURL: one of the above URL format\nPush: <refspec>\nPull: <refspec>\n\nPush: lines are used by git push and Pull: lines are used by git pull\nand git fetch. Multiple Push: and Pull: lines may be specified for\nadditional branch mappings.\n\nNamed file in $GITDIR/branches\nYou can choose to provide the name of a file in $GITDIR/branches. The\nURL in this file will be used to access the repository. This file\nshould have the following format:\n\n<url>#<head>\n\n<url> is required; #<head> is optional.\n\nDepending on the operation, git will use one of the following refspecs,\nif you don't provide one on the command line. <branch> is the name of\nthis file in $GITDIR/branches and <head> defaults to master.\n\ngit fetch uses:\n\nrefs/heads/<head>:refs/heads/<branch>\n\ngit push uses:\n\nHEAD:refs/heads/<head>\n",
            "subsections": []
        },
        "OUTPUT": {
            "content": "The output of \"git push\" depends on the transport method used; this\nsection describes the output when pushing over the Git protocol (either\nlocally or via ssh).\n\nThe status of the push is output in tabular form, with each line\nrepresenting the status of a single ref. Each line is of the form:\n\n<flag> <summary> <from> -> <to> (<reason>)\n\nIf --porcelain is used, then each line of the output is of the form:\n\n<flag> \\t <from>:<to> \\t <summary> (<reason>)\n\nThe status of up-to-date refs is shown only if --porcelain or --verbose\noption is used.\n\nflag\nA single character indicating the status of the ref:\n\n(space)\nfor a successfully pushed fast-forward;\n\n+\nfor a successful forced update;\n\n-\nfor a successfully deleted ref;\n\n*\nfor a successfully pushed new ref;\n\n!\nfor a ref that was rejected or failed to push; and\n\n=\nfor a ref that was up to date and did not need pushing.\n\nsummary\nFor a successfully pushed ref, the summary shows the old and new\nvalues of the ref in a form suitable for using as an argument to\ngit log (this is <old>..<new> in most cases, and <old>...<new> for\nforced non-fast-forward updates).\n\nFor a failed update, more details are given:\n\nrejected\nGit did not try to send the ref at all, typically because it is\nnot a fast-forward and you did not force the update.\n\nremote rejected\nThe remote end refused the update. Usually caused by a hook on\nthe remote side, or because the remote repository has one of\nthe following safety options in effect:\nreceive.denyCurrentBranch (for pushes to the checked out\nbranch), receive.denyNonFastForwards (for forced\nnon-fast-forward updates), receive.denyDeletes or\nreceive.denyDeleteCurrent. See git-config(1).\n\nremote failure\nThe remote end did not report the successful update of the ref,\nperhaps because of a temporary error on the remote side, a\nbreak in the network connection, or other transient error.\n\nfrom\nThe name of the local ref being pushed, minus its refs/<type>/\nprefix. In the case of deletion, the name of the local ref is\nomitted.\n\nto\nThe name of the remote ref being updated, minus its refs/<type>/\nprefix.\n\nreason\nA human-readable explanation. In the case of successfully pushed\nrefs, no explanation is needed. For a failed ref, the reason for\nfailure is described.\n",
            "subsections": []
        },
        "NOTE ABOUT FAST-FORWARDS": {
            "content": "When an update changes a branch (or more in general, a ref) that used\nto point at commit A to point at another commit B, it is called a\nfast-forward update if and only if B is a descendant of A.\n\nIn a fast-forward update from A to B, the set of commits that the\noriginal commit A built on top of is a subset of the commits the new\ncommit B builds on top of. Hence, it does not lose any history.\n\nIn contrast, a non-fast-forward update will lose history. For example,\nsuppose you and somebody else started at the same commit X, and you\nbuilt a history leading to commit B while the other person built a\nhistory leading to commit A. The history looks like this:\n\nB\n/\n---X---A\n\nFurther suppose that the other person already pushed changes leading to\nA back to the original repository from which you two obtained the\noriginal commit X.\n\nThe push done by the other person updated the branch that used to point\nat commit X to point at commit A. It is a fast-forward.\n\nBut if you try to push, you will attempt to update the branch (that now\npoints at A) with commit B. This does not fast-forward. If you did so,\nthe changes introduced by commit A will be lost, because everybody will\nnow start building on top of B.\n\nThe command by default does not allow an update that is not a\nfast-forward to prevent such loss of history.\n\nIf you do not want to lose your work (history from X to B) or the work\nby the other person (history from X to A), you would need to first\nfetch the history from the repository, create a history that contains\nchanges done by both parties, and push the result back.\n\nYou can perform \"git pull\", resolve potential conflicts, and \"git push\"\nthe result. A \"git pull\" will create a merge commit C between commits A\nand B.\n\nB---C\n/   /\n---X---A\n\nUpdating A with the resulting merge commit will fast-forward and your\npush will be accepted.\n\nAlternatively, you can rebase your change between X and B on top of A,\nwith \"git pull --rebase\", and push the result back. The rebase will\ncreate a new commit D that builds the change between X and B on top of\nA.\n\nB   D\n/   /\n---X---A\n\nAgain, updating A with this commit will fast-forward and your push will\nbe accepted.\n\nThere is another common situation where you may encounter\nnon-fast-forward rejection when you try to push, and it is possible\neven when you are pushing into a repository nobody else pushes into.\nAfter you push commit A yourself (in the first picture in this\nsection), replace it with \"git commit --amend\" to produce commit B, and\nyou try to push it out, because forgot that you have pushed A out\nalready. In such a case, and only if you are certain that nobody in the\nmeantime fetched your earlier commit A (and started building on top of\nit), you can run \"git push --force\" to overwrite it. In other words,\n\"git push --force\" is a method reserved for a case where you do mean to\nlose history.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "git push\nWorks like git push <remote>, where <remote> is the current\nbranch's remote (or origin, if no remote is configured for the\ncurrent branch).\n\ngit push origin\nWithout additional configuration, pushes the current branch to the\nconfigured upstream (branch.<name>.merge configuration variable) if\nit has the same name as the current branch, and errors out without\npushing otherwise.\n\nThe default behavior of this command when no <refspec> is given can\nbe configured by setting the push option of the remote, or the\npush.default configuration variable.\n\nFor example, to default to pushing only the current branch to\norigin use git config remote.origin.push HEAD. Any valid <refspec>\n(like the ones in the examples below) can be configured as the\ndefault for git push origin.\n\ngit push origin :\nPush \"matching\" branches to origin. See <refspec> in the OPTIONS\nsection above for a description of \"matching\" branches.\n\ngit push origin master\nFind a ref that matches master in the source repository (most\nlikely, it would find refs/heads/master), and update the same ref\n(e.g.  refs/heads/master) in origin repository with it. If master\ndid not exist remotely, it would be created.\n\ngit push origin HEAD\nA handy way to push the current branch to the same name on the\nremote.\n\ngit push mothership master:satellite/master dev:satellite/dev\nUse the source ref that matches master (e.g.  refs/heads/master) to\nupdate the ref that matches satellite/master (most probably\nrefs/remotes/satellite/master) in the mothership repository; do the\nsame for dev and satellite/dev.\n\nSee the section describing <refspec>...  above for a discussion of\nthe matching semantics.\n\nThis is to emulate git fetch run on the mothership using git push\nthat is run in the opposite direction in order to integrate the\nwork done on satellite, and is often necessary when you can only\nmake connection in one way (i.e. satellite can ssh into mothership\nbut mothership cannot initiate connection to satellite because the\nlatter is behind a firewall or does not run sshd).\n\nAfter running this git push on the satellite machine, you would ssh\ninto the mothership and run git merge there to complete the\nemulation of git pull that were run on mothership to pull changes\nmade on satellite.\n\ngit push origin HEAD:master\nPush the current branch to the remote ref matching master in the\norigin repository. This form is convenient to push the current\nbranch without thinking about its local name.\n\ngit push origin master:refs/heads/experimental\nCreate the branch experimental in the origin repository by copying\nthe current master branch. This form is only needed to create a new\nbranch or tag in the remote repository when the local name and the\nremote name are different; otherwise, the ref name on its own will\nwork.\n\ngit push origin :experimental\nFind a ref that matches experimental in the origin repository (e.g.\nrefs/heads/experimental), and delete it.\n\ngit push origin +dev:master\nUpdate the origin repository's master branch with the dev branch,\nallowing non-fast-forward updates.  This can leave unreferenced\ncommits dangling in the origin repository.  Consider the following\nsituation, where a fast-forward is not possible:\n\no---o---o---A---B  origin/master\n\\\nX---Y---Z  dev\n\nThe above command would change the origin repository to\n\nA---B  (unnamed branch)\n/\no---o---o---X---Y---Z  master\n\nCommits A and B would no longer belong to a branch with a symbolic\nname, and so would be unreachable. As such, these commits would be\nremoved by a git gc command on the origin repository.\n",
            "subsections": []
        },
        "SECURITY": {
            "content": "The fetch and push protocols are not designed to prevent one side from\nstealing data from the other repository that was not intended to be\nshared. If you have private data that you need to protect from a\nmalicious peer, your best option is to store it in another repository.\nThis applies to both clients and servers. In particular, namespaces on\na server are not effective for read access control; you should only\ngrant read access to a namespace to clients that you would trust with\nread access to the entire repository.\n\nThe known attack vectors are as follows:\n\n1. The victim sends \"have\" lines advertising the IDs of objects it has\nthat are not explicitly intended to be shared but can be used to\noptimize the transfer if the peer also has them. The attacker\nchooses an object ID X to steal and sends a ref to X, but isn't\nrequired to send the content of X because the victim already has\nit. Now the victim believes that the attacker has X, and it sends\nthe content of X back to the attacker later. (This attack is most\nstraightforward for a client to perform on a server, by creating a\nref to X in the namespace the client has access to and then\nfetching it. The most likely way for a server to perform it on a\nclient is to \"merge\" X into a public branch and hope that the user\ndoes additional work on this branch and pushes it back to the\nserver without noticing the merge.)\n\n2. As in #1, the attacker chooses an object ID X to steal. The victim\nsends an object Y that the attacker already has, and the attacker\nfalsely claims to have X and not Y, so the victim sends Y as a\ndelta against X. The delta reveals regions of X that are similar to\nY to the attacker.\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\nGit 2.34.1                        02/26/2026                       GIT-PUSH(1)",
            "subsections": []
        }
    },
    "summary": "git-push - Update remote refs along with associated objects",
    "flags": [
        {
            "flag": "",
            "long": "--all",
            "arg": null,
            "description": "Push all branches (i.e. refs under refs/heads/); cannot be used with other <refspec>."
        },
        {
            "flag": "",
            "long": "--prune",
            "arg": null,
            "description": "Remove remote branches that don't have a local counterpart. For example a remote branch tmp will be removed if a local branch with the same name doesn't exist any more. This also respects refspecs, e.g. git push --prune remote refs/heads/*:refs/tmp/* would make sure that remote refs/tmp/foo will be removed if refs/heads/foo doesn't exist."
        },
        {
            "flag": "",
            "long": "--mirror",
            "arg": null,
            "description": "Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set."
        },
        {
            "flag": "-n",
            "long": "--dry-run",
            "arg": null,
            "description": "Do everything except actually send the updates."
        },
        {
            "flag": "",
            "long": "--porcelain",
            "arg": null,
            "description": "Produce machine-readable output. The output status line for each ref will be tab-separated and sent to stdout instead of stderr. The full symbolic names of the refs will be given."
        },
        {
            "flag": "-d",
            "long": "--delete",
            "arg": null,
            "description": "All listed refs are deleted from the remote repository. This is the same as prefixing all refs with a colon."
        },
        {
            "flag": "",
            "long": "--tags",
            "arg": null,
            "description": "All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line."
        },
        {
            "flag": "",
            "long": "--follow-tags",
            "arg": null,
            "description": "Push all the refs that would be pushed without this option, and also push annotated tags in refs/tags that are missing from the remote but are pointing at commit-ish that are reachable from the refs being pushed. This can also be specified with configuration variable push.followTags. For more information, see push.followTags in git-config(1). --[no-]signed, --signed=(true|false|if-asked) GPG-sign the push request to update refs on the receiving side, to allow it to be checked by the hooks and/or be logged. If false or --no-signed, no signing will be attempted. If true or --signed, the push will fail if the server does not support signed pushes. If set to if-asked, sign if and only if the server supports signed pushes. The push will also fail if the actual call to gpg --sign fails. See git-receive-pack(1) for the details on the receiving end. --[no-]atomic Use an atomic transaction on the remote side if available. Either all refs are updated, or on error, no refs are updated. If the server does not support atomic pushes the push will fail. -o <option>, --push-option=<option> Transmit the given string to the server, which passes them to the pre-receive as well as the post-receive hook. The given string must not contain a NUL or LF character. When multiple --push-option=<option> are given, they are all sent to the other side in the order listed on the command line. When no --push-option=<option> is given from the command line, the values of configuration variable push.pushOption are used instead. --receive-pack=<git-receive-pack>, --exec=<git-receive-pack> Path to the git-receive-pack program on the remote end. Sometimes useful when pushing to a remote repository over ssh, and you do not have the program in a directory on the default $PATH. --[no-]force-with-lease, --force-with-lease=<refname>, --force-with-lease=<refname>:<expect> Usually, \"git push\" refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This option overrides this restriction if the current value of the remote ref is the expected value. \"git push\" fails otherwise. Imagine that you have to rebase what you have already published. You will have to bypass the \"must fast-forward\" rule in order to replace the history you originally published with the rebased history. If somebody else built on top of your original history while you are rebasing, the tip of the branch at the remote may advance with their commit, and blindly pushing with --force will lose their work. This option allows you to say that you expect the history you are updating is what you rebased and want to replace. If the remote ref still points at the commit you specified, you can be sure that no other people did anything to the ref. It is like taking a \"lease\" on the ref without explicitly locking it, and the remote ref is updated only if the \"lease\" is still valid. --force-with-lease alone, without specifying the details, will protect all remote refs that are going to be updated by requiring their current value to be the same as the remote-tracking branch we have for them. --force-with-lease=<refname>, without specifying the expected value, will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the remote-tracking branch we have for it. --force-with-lease=<refname>:<expect> will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the specified value <expect> (which is allowed to be different from the remote-tracking branch we have for the refname, or we do not even have to have such a remote-tracking branch when this form is used). If <expect> is the empty string, then the named ref must not already exist. Note that all forms other than --force-with-lease=<refname>:<expect> that specifies the expected current value of the ref explicitly are still experimental and their semantics may change as we gain experience with this feature. \"--no-force-with-lease\" will cancel all the previous --force-with-lease on the command line. A general note on safety: supplying this option without an expected value, i.e. as --force-with-lease or --force-with-lease=<refname> interacts very badly with anything that implicitly runs git fetch on the remote to be pushed to in the background, e.g. git fetch origin on your repository in a cronjob. The protection it offers over --force is ensuring that subsequent changes your work wasn't based on aren't clobbered, but this is trivially defeated if some background process is updating refs in the background. We don't have anything except the remote tracking info to go by as a heuristic for refs you're expected to have seen & are willing to clobber. If your editor or some other system is running git fetch in the background for you a way to mitigate this is to simply set up another remote: git remote add origin-push $(git config remote.origin.url) git fetch origin-push Now when the background process runs git fetch origin the references on origin-push won't be updated, and thus commands like: git push --force-with-lease origin-push Will fail unless you manually run git fetch origin-push. This method is of course entirely defeated by something that runs git fetch --all, in that case you'd need to either disable it or do something more tedious like: git fetch # update 'master' from remote git tag base master # mark our base point git rebase -i master # rewrite some commits git push --force-with-lease=master:base master:master I.e. create a base tag for versions of the upstream code that you've seen and are willing to overwrite, then rewrite history, and finally force push changes to master if the remote version is still at base, regardless of what your local remotes/origin/master has been updated to in the background. Alternatively, specifying --force-if-includes as an ancillary option along with --force-with-lease[=<refname>] (i.e., without saying what exact commit the ref on the remote side must be pointing at, or which refs on the remote side are being protected) at the time of \"push\" will verify if updates from the remote-tracking refs that may have been implicitly updated in the background are integrated locally before allowing a forced update."
        },
        {
            "flag": "-f",
            "long": "--force",
            "arg": null,
            "description": "Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. Also, when --force-with-lease option is used, the command refuses to update a remote ref whose current value does not match what is expected. This flag disables these checks, and can cause the remote repository to lose commits; use it with care. Note that --force applies to all the refs that are pushed, hence using it with push.default set to matching or with multiple push destinations configured with remote.*.push may overwrite refs other than the current branch (including local refs that are strictly behind their remote counterpart). To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch). See the <refspec>... section above for details. --[no-]force-if-includes Force an update only if the tip of the remote-tracking ref has been integrated locally. This option enables a check that verifies if the tip of the remote-tracking ref is reachable from one of the \"reflog\" entries of the local branch based in it for a rewrite. The check ensures that any updates from the remote have been incorporated locally by rejecting the forced update if that is not the case. If the option is passed without specifying --force-with-lease, or specified along with --force-with-lease=<refname>:<expect>, it is a \"no-op\". Specifying --no-force-if-includes disables this behavior. --repo=<repository> This option is equivalent to the <repository> argument. If both are specified, the command-line argument takes precedence."
        },
        {
            "flag": "-u",
            "long": "--set-upstream",
            "arg": null,
            "description": "For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch.<name>.merge in git-config(1). --[no-]thin These options are passed to git-send-pack(1). A thin transfer significantly reduces the amount of sent data when the sender and receiver share many of the same objects in common. The default is --thin."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "Suppress all output, including the listing of updated refs, unless an error occurs. Progress is not reported to the standard error stream."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "Run verbosely."
        },
        {
            "flag": "",
            "long": "--progress",
            "arg": null,
            "description": "Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal. --no-recurse-submodules, --recurse-submodules=check|on-demand|only|no May be used to make sure all submodule commits used by the revisions to be pushed are available on a remote-tracking branch. If check is used Git will verify that all submodule commits that changed in the revisions to be pushed are available on at least one remote of the submodule. If any commits are missing the push will be aborted and exit with non-zero status. If on-demand is used all submodules that changed in the revisions to be pushed will be pushed. If on-demand was not able to push all necessary revisions it will also be aborted and exit with non-zero status. If only is used all submodules will be recursively pushed while the superproject is left unpushed. A value of no or using --no-recurse-submodules can be used to override the push.recurseSubmodules configuration variable when no submodule recursion is required. --[no-]verify Toggle the pre-push hook (see githooks(5)). The default is --verify, giving the hook a chance to prevent the push. With --no-verify, the hook is bypassed completely. -4, --ipv4 Use IPv4 addresses only, ignoring IPv6 addresses. -6, --ipv6 Use IPv6 addresses only, ignoring IPv4 addresses."
        }
    ],
    "examples": [
        "git push",
        "Works like git push <remote>, where <remote> is the current",
        "branch's remote (or origin, if no remote is configured for the",
        "current branch).",
        "git push origin",
        "Without additional configuration, pushes the current branch to the",
        "configured upstream (branch.<name>.merge configuration variable) if",
        "it has the same name as the current branch, and errors out without",
        "pushing otherwise.",
        "The default behavior of this command when no <refspec> is given can",
        "be configured by setting the push option of the remote, or the",
        "push.default configuration variable.",
        "For example, to default to pushing only the current branch to",
        "origin use git config remote.origin.push HEAD. Any valid <refspec>",
        "(like the ones in the examples below) can be configured as the",
        "default for git push origin.",
        "git push origin :",
        "Push \"matching\" branches to origin. See <refspec> in the OPTIONS",
        "section above for a description of \"matching\" branches.",
        "git push origin master",
        "Find a ref that matches master in the source repository (most",
        "likely, it would find refs/heads/master), and update the same ref",
        "(e.g.  refs/heads/master) in origin repository with it. If master",
        "did not exist remotely, it would be created.",
        "git push origin HEAD",
        "A handy way to push the current branch to the same name on the",
        "remote.",
        "git push mothership master:satellite/master dev:satellite/dev",
        "Use the source ref that matches master (e.g.  refs/heads/master) to",
        "update the ref that matches satellite/master (most probably",
        "refs/remotes/satellite/master) in the mothership repository; do the",
        "same for dev and satellite/dev.",
        "See the section describing <refspec>...  above for a discussion of",
        "the matching semantics.",
        "This is to emulate git fetch run on the mothership using git push",
        "that is run in the opposite direction in order to integrate the",
        "work done on satellite, and is often necessary when you can only",
        "make connection in one way (i.e. satellite can ssh into mothership",
        "but mothership cannot initiate connection to satellite because the",
        "latter is behind a firewall or does not run sshd).",
        "After running this git push on the satellite machine, you would ssh",
        "into the mothership and run git merge there to complete the",
        "emulation of git pull that were run on mothership to pull changes",
        "made on satellite.",
        "git push origin HEAD:master",
        "Push the current branch to the remote ref matching master in the",
        "origin repository. This form is convenient to push the current",
        "branch without thinking about its local name.",
        "git push origin master:refs/heads/experimental",
        "Create the branch experimental in the origin repository by copying",
        "the current master branch. This form is only needed to create a new",
        "branch or tag in the remote repository when the local name and the",
        "remote name are different; otherwise, the ref name on its own will",
        "work.",
        "git push origin :experimental",
        "Find a ref that matches experimental in the origin repository (e.g.",
        "refs/heads/experimental), and delete it.",
        "git push origin +dev:master",
        "Update the origin repository's master branch with the dev branch,",
        "allowing non-fast-forward updates.  This can leave unreferenced",
        "commits dangling in the origin repository.  Consider the following",
        "situation, where a fast-forward is not possible:",
        "o---o---o---A---B  origin/master",
        "X---Y---Z  dev",
        "The above command would change the origin repository to",
        "A---B  (unnamed branch)",
        "o---o---o---X---Y---Z  master",
        "Commits A and B would no longer belong to a branch with a symbolic",
        "name, and so would be unreachable. As such, these commits would be",
        "removed by a git gc command on the origin repository."
    ],
    "see_also": []
}