{
    "mode": "man",
    "parameter": "git-push",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-push/1/json",
    "generated": "2026-06-10T23:28:23Z",
    "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\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Updates remote refs using local refs, while sending objects necessary to complete the given\nrefs.\n\nYou can make interesting things happen to a repository every time you push into it, by\nsetting up hooks there. See documentation for git-receive-pack(1).\n\nWhen the command line does not specify where to push with the <repository> argument,\nbranch.*.remote configuration for the current branch is consulted to determine where to push.\nIf the configuration is missing, it defaults to origin.\n\nWhen the command line does not specify what to push with <refspec>... arguments or --all,\n--mirror, --tags options, the command finds the default <refspec> by consulting remote.*.push\nconfiguration, and if it is not found, honors push.default configuration to decide what to\npush (See git-config(1) for the meaning of push.default).\n\nWhen neither the command-line nor the configuration specify what to push, the default\nbehavior is used, which corresponds to the simple value for push.default: the current branch\nis pushed to the corresponding upstream branch, but as a safety measure, the push is aborted\nif the upstream branch does not have the same name as the local one.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "<repository>\nThe \"remote\" repository that is destination of a push operation. This parameter can be\neither a URL (see the section GIT URLS below) or the name of a remote (see the section\nREMOTES below).\n\n<refspec>...\nSpecify what destination ref to update with what source object. The format of a <refspec>\nparameter is an optional plus +, followed by the source object <src>, followed by a colon\n:, followed by the destination ref <dst>.\n\nThe <src> is often the name of the branch you would want to push, but it can be any\narbitrary \"SHA-1 expression\", such as master~4 or HEAD (see gitrevisions(7)).\n\nThe <dst> tells which ref on the remote side is updated with this push. Arbitrary\nexpressions cannot be used here, an actual ref must be named. If git push [<repository>]\nwithout any <refspec> argument is set to update some ref at the destination with <src>\nwith remote.<repository>.push configuration variable, :<dst> part can be omitted—such a\npush will update a ref that <src> normally updates without any <refspec> on the command\nline. Otherwise, missing :<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 try to infer where in\nrefs/* on the destination <repository> it belongs based on the type of <src> being pushed\nand whether <dst> is ambiguous.\n\n•   If <dst> unambiguously refers to a ref on the <repository> remote, then push to that\nref.\n\n•   If <src> resolves to a ref starting with refs/heads/ or refs/tags/, then prepend that\nto <dst>.\n\n•   Other ambiguity resolutions might be added in the future, but for now any other cases\nwill error out with an error indicating what we tried, and depending on the\nadvice.pushUnqualifiedRefname configuration (see git-config(1)) suggest what refs/\nnamespace you may have wanted to push to.\n\nThe object referenced by <src> is used to update the <dst> reference on the remote side.\nWhether this is allowed depends on where in refs/* the <dst> reference lives as described\nin detail below, in those sections \"update\" means any modifications except deletes, which\nas noted after the next few sections are treated differently.\n\nThe refs/heads/* namespace will only accept commit objects, and updates only if they can\nbe fast-forwarded.\n\nThe refs/tags/* namespace will accept any kind of object (as commits, trees and blobs can\nbe tagged), and any updates to them will be rejected.\n\nIt’s possible to push any type of object to any namespace outside of refs/{tags,heads}/*.\nIn the case of tags and commits, these will be treated as if they were the commits inside\nrefs/heads/* for the purposes of whether the update is allowed.\n\nI.e. a fast-forward of commits and tags outside refs/{tags,heads}/* is allowed, even in\ncases where what’s being fast-forwarded is not a commit, but a tag object which happens\nto point to a new commit which is a fast-forward of the commit the last tag (or commit)\nit’s replacing. Replacing a tag with an entirely different tag is also allowed, if it\npoints to the same commit, as well as pushing a peeled tag, i.e. pushing the commit that\nexisting tag object points to, or a new tag object which an existing commit points to.\n\nTree and blob objects outside of refs/{tags,heads}/* will be treated the same way as if\nthey were inside refs/tags/*, any update of them will be rejected.\n\nAll of the rules described above about what’s not allowed as an update can be overridden\nby adding an the optional leading + to a refspec (or using --force command line option).\nThe only exception to this is that no amount of forcing will make the refs/heads/*\nnamespace accept a non-commit object. Hooks and configuration can also override or amend\nthese rules, see e.g.  receive.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 remote repository.\nDeletions are always accepted without a leading + in the refspec (or --force), except\nwhen forbidden by configuration or hooks. See receive.denyDeletes in git-config(1) and\npre-receive and update in githooks(5).\n\nThe special refspec : (or +: to allow non-fast-forward updates) directs Git to push\n\"matching\" branches: for every branch that exists on the local side, the remote side is\nupdated if a branch of the 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 with other <refspec>.\n",
                    "long": "--all"
                },
                {
                    "name": "--prune",
                    "content": "Remove remote branches that don’t have a local counterpart. For example a remote branch\ntmp will be removed if a local branch with the same name doesn’t exist any more. This\nalso respects refspecs, e.g.  git push --prune remote refs/heads/*:refs/tmp/* would make\nsure that remote refs/tmp/foo will be removed if refs/heads/foo doesn’t exist.\n",
                    "long": "--prune"
                },
                {
                    "name": "--mirror",
                    "content": "Instead of naming each ref to push, specifies that all refs under refs/ (which includes\nbut is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the\nremote repository. Newly created local refs will be pushed to the remote end, locally\nupdated refs will be force updated on the remote end, and deleted refs will be removed\nfrom the remote end. This is the default if the configuration option\nremote.<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 ref will be\ntab-separated and sent to stdout instead of stderr. The full symbolic names of the refs\nwill be given.\n",
                    "long": "--porcelain"
                },
                {
                    "name": "-d, --delete",
                    "content": "All listed refs are deleted from the remote repository. This is the same as prefixing all\nrefs with a colon.\n",
                    "flag": "-d",
                    "long": "--delete"
                },
                {
                    "name": "--tags",
                    "content": "All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the\ncommand line.\n",
                    "long": "--tags"
                },
                {
                    "name": "--follow-tags",
                    "content": "Push all the refs that would be pushed without this option, and also push annotated tags\nin refs/tags that are missing from the remote but are pointing at commit-ish that are\nreachable from the refs being pushed. This can also be specified with configuration\nvariable push.followTags. For more information, see push.followTags in 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 allow it to be checked\nby the hooks and/or be logged. If false or --no-signed, no signing will be attempted. If\ntrue or --signed, the push 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. The push will also\nfail if the actual call to gpg --sign fails. See git-receive-pack(1) for the details on\nthe receiving end.\n\n--[no-]atomic\nUse an atomic transaction on the remote side if available. Either all refs are updated,\nor on error, no refs are updated. If the server does not support atomic pushes the push\nwill fail.\n\n-o <option>, --push-option=<option>\nTransmit the given string to the server, which passes them to the pre-receive as well as\nthe post-receive hook. The given string must not contain a NUL or LF character. When\nmultiple --push-option=<option> are given, they are all sent to the other side in the\norder listed on the command line. When no --push-option=<option> is given from the\ncommand line, the values of 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 useful when pushing to\na remote repository over ssh, and you do not have the program in a directory on the\ndefault $PATH.\n\n--[no-]force-with-lease, --force-with-lease=<refname>, --force-with-lease=<refname>:<expect>\nUsually, \"git push\" refuses to update a remote ref that is not an ancestor of the local\nref used to overwrite it.\n\nThis option overrides this restriction if the current value of the remote ref is the\nexpected value. \"git push\" fails otherwise.\n\nImagine that you have to rebase what you have already published. You will have to bypass\nthe \"must fast-forward\" rule in order to replace the history you originally published\nwith the rebased history. If somebody else built on top of your original history while\nyou are rebasing, the tip of the branch at the remote may advance with their commit, and\nblindly pushing with --force will lose their work.\n\nThis option allows you to say that you expect the history you are updating is what you\nrebased and want to replace. If the remote ref still points at the commit you specified,\nyou can be sure that no other people did anything to the ref. It is like taking a \"lease\"\non the ref without explicitly locking it, and the remote ref is updated only if the\n\"lease\" is still valid.\n\n--force-with-lease alone, without specifying the details, will protect all remote refs\nthat are going to be updated by requiring their current value to be the same as the\nremote-tracking branch we have for them.\n\n--force-with-lease=<refname>, without specifying the expected value, will protect the\nnamed ref (alone), if it is going to be updated, by requiring its current value to be the\nsame as the remote-tracking branch we have for it.\n\n--force-with-lease=<refname>:<expect> will protect the named ref (alone), if it is going\nto be updated, by requiring its current value to be the same as the specified value\n<expect> (which is allowed 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 branch when this form\nis used). If <expect> is the empty string, then the named ref must not already exist.\n\nNote that all forms other than --force-with-lease=<refname>:<expect> that specifies the\nexpected current value of the ref explicitly are still experimental and their semantics\nmay change as we gain experience with this feature.\n\n\"--no-force-with-lease\" will cancel all the previous --force-with-lease on the command\nline.\n\nA general note on safety: supplying this option without an expected value, i.e. as\n--force-with-lease or --force-with-lease=<refname> interacts very badly with anything\nthat implicitly runs git fetch on the remote to be pushed to in the background, e.g.  git\nfetch origin on your repository in a cronjob.\n\nThe protection it offers over --force is ensuring that subsequent changes your work\nwasn’t based on aren’t clobbered, but this is trivially defeated if some background\nprocess is updating refs in the background. We don’t have anything except the remote\ntracking info to go by as a heuristic for refs you’re expected to have seen & are willing\nto clobber.\n\nIf your editor or some other system is running git fetch in the background for you a way\nto mitigate this is to simply set up another 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 references on origin-push won’t\nbe 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 method is of course\nentirely defeated by something that runs git fetch --all, in that case you’d need to\neither disable it or do something 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 you’ve seen and are willing\nto overwrite, then rewrite history, and finally force push changes to master if the\nremote version is still at 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 option along with\n--force-with-lease[=<refname>] (i.e., without saying what exact commit the ref on the\nremote side must be pointing at, or which refs on the remote side are being protected) at\nthe time of \"push\" will verify if updates from the remote-tracking refs that may have\nbeen implicitly updated in the background are integrated locally before allowing a forced\nupdate.\n",
                    "long": "--follow-tags"
                },
                {
                    "name": "-f, --force",
                    "content": "Usually, the command refuses to update a remote ref that is not an ancestor of the local\nref used to overwrite it. Also, when --force-with-lease option is used, the command\nrefuses to update a remote ref whose current value does not match what is expected.\n\nThis flag disables these checks, and can cause the remote repository to lose commits; use\nit with care.\n\nNote that --force applies to all the refs that are pushed, hence using it with\npush.default set to matching or with multiple push destinations configured with\nremote.*.push may overwrite refs other than the current branch (including local refs that\nare strictly behind their remote counterpart). To force a push to only one branch, use a\n+ in front of the refspec to push (e.g git push origin +master to force a push to the\nmaster branch). See the <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 integrated locally.\n\nThis option enables a check that verifies if the tip of the remote-tracking ref is\nreachable from one of the \"reflog\" entries of the local branch based in it for a rewrite.\nThe check ensures that 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 specified along with\n--force-with-lease=<refname>:<expect>, it is a \"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 specified, the\ncommand-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 upstream (tracking)\nreference, used by argument-less git-pull(1) and other commands. For more information,\nsee branch.<name>.merge in git-config(1).\n\n--[no-]thin\nThese options are passed to git-send-pack(1). A thin transfer significantly reduces the\namount of sent data when the sender and receiver share many of the same objects in\ncommon. The default is --thin.\n",
                    "flag": "-u",
                    "long": "--set-upstream"
                },
                {
                    "name": "-q, --quiet",
                    "content": "Suppress all output, including the listing of updated refs, unless an error occurs.\nProgress is not reported to the standard error stream.\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 when it is attached\nto a terminal, unless -q is specified. This flag forces progress status even if the\nstandard error stream is not 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 revisions to be pushed are\navailable on a remote-tracking branch. If check is used Git will verify that all\nsubmodule commits that changed in the revisions to be pushed are available on at least\none remote of the submodule. If any commits are missing the push will be aborted and exit\nwith non-zero status. If on-demand is used all submodules that changed in the revisions\nto be pushed will be pushed. If on-demand was not able to push all necessary revisions it\nwill also be aborted and exit with non-zero status. If only is used all submodules will\nbe recursively pushed while the superproject is left unpushed. A value of no or using\n--no-recurse-submodules can be used to override the push.recurseSubmodules configuration\nvariable when no submodule recursion is required.\n\n--[no-]verify\nToggle the pre-push hook (see githooks(5)). The default is --verify, giving the hook a\nchance to prevent the push. With --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 address of the remote\nserver, and the path to the repository. Depending on the transport protocol, some of this\ninformation may be absent.\n\nGit supports ssh, git, http, and https protocols (in addition, ftp, and ftps can be used for\nfetching, but this is inefficient and deprecated; do not use it).\n\nThe native transport (i.e. git:// URL) does no authentication and should be used with caution\non unsecured networks.\n\nThe following syntaxes may be used with them:\n\n•   ssh://[user@]host.xz[:port]/path/to/repo.git/\n\n•   git://host.xz[:port]/path/to/repo.git/\n\n•   http[s]://host.xz[:port]/path/to/repo.git/\n\n•   ftp[s]://host.xz[:port]/path/to/repo.git/\n\nAn alternative scp-like syntax may also be used with the ssh protocol:\n\n•   [user@]host.xz:path/to/repo.git/\n\nThis syntax is only recognized if there are no slashes before the first colon. This helps\ndifferentiate a local path that contains a colon. For example the local path foo:bar could be\nspecified as an absolute path or ./foo:bar to avoid being misinterpreted as an ssh url.\n\nThe ssh and git protocols additionally support ~username expansion:\n\n•   ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/\n\n•   git://host.xz[:port]/~[user]/path/to/repo.git/\n\n•   [user@]host.xz:/~[user]/path/to/repo.git/\n\nFor local repositories, also supported by Git natively, the following syntaxes may be used:\n\n•   /path/to/repo.git/\n\n•   file:///path/to/repo.git/\n\nThese two syntaxes are mostly equivalent, except when cloning, when the former implies\n--local option. See git-clone(1) for details.\n\ngit clone, git fetch and git pull, but not git push, will also accept a suitable bundle file.\nSee git-bundle(1).\n\nWhen Git doesn’t know how to handle a certain transport protocol, it attempts to use the\nremote-<transport> remote helper, if one exists. To explicitly request a remote helper, the\nfollowing syntax may be used:\n\n•   <transport>::<address>\n\nwhere <address> may be a path, a server and path, or an arbitrary URL-like string recognized\nby the specific remote helper being invoked. See gitremote-helpers(7) for details.\n\nIf there are a large number of similarly-named remote repositories and you want to use a\ndifferent format for them (such that the URLs you use will be rewritten into URLs that work),\nyou can create a configuration section of the form:\n\n[url \"<actual url base>\"]\ninsteadOf = <other url base>\n\n\nFor example, with this:\n\n[url \"git://git.host.xz/\"]\ninsteadOf = host.xz:/path/to/\ninsteadOf = work:\n\n\na URL like \"work:repo.git\" or like \"host.xz:/path/to/repo.git\" will be rewritten in any\ncontext that takes a URL to be \"git://git.host.xz/repo.git\".\n\nIf you want to rewrite URLs for push only, you can create a configuration section of the\nform:\n\n[url \"<actual url base>\"]\npushInsteadOf = <other url base>\n\n\nFor example, with this:\n\n[url \"ssh://example.org/\"]\npushInsteadOf = git://example.org/\n\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 use the original URL.\n",
            "subsections": []
        },
        "REMOTES": {
            "content": "The name of one of the following can be used instead of a URL as <repository> argument:\n\n•   a remote in the Git configuration file: $GITDIR/config,\n\n•   a file in the $GITDIR/remotes directory, or\n\n•   a file in the $GITDIR/branches directory.\n\nAll of these also allow you to omit the refspec from the command line because they each\ncontain a refspec which git will use by default.\n",
            "subsections": [
                {
                    "name": "Named remote in configuration file",
                    "content": "You can choose to provide the name of a remote which you had previously configured using git-\nremote(1), git-config(1) or even by a manual edit to the $GITDIR/config file. The URL of\nthis remote will be used to access the repository. The refspec of this remote will be used by\ndefault when you do not provide a refspec on the command line. The entry in the config file\nwould appear like this:\n\n[remote \"<name>\"]\nurl = <url>\npushurl = <pushurl>\npush = <refspec>\nfetch = <refspec>\n\n\nThe <pushurl> is used for pushes only. It is optional and defaults to <url>.\n\nNamed file in $GITDIR/remotes\nYou can choose to provide the name of a file in $GITDIR/remotes. The URL in this file will\nbe used to access the repository. The refspec in this file will be used as default when you\ndo not provide a refspec on the command line. This file should have the following format:\n\nURL: one of the above URL format\nPush: <refspec>\nPull: <refspec>\n\n\nPush: lines are used by git push and Pull: lines are used by git pull and git fetch. Multiple\nPush: and Pull: lines may be specified for additional branch mappings.\n\nNamed file in $GITDIR/branches\nYou can choose to provide the name of a file in $GITDIR/branches. The URL in this file will\nbe used to access the repository. This file should have the following format:\n\n<url>#<head>\n\n\n<url> is required; #<head> is optional.\n\nDepending on the operation, git will use one of the following refspecs, if you don’t provide\none on the command line. <branch> is the name of this file in $GITDIR/branches and <head>\ndefaults to master.\n\ngit fetch uses:\n\nrefs/heads/<head>:refs/heads/<branch>\n\n\ngit push uses:\n\nHEAD:refs/heads/<head>\n\n"
                }
            ]
        },
        "OUTPUT": {
            "content": "The output of \"git push\" depends on the transport method used; this section describes the\noutput when pushing over the Git protocol (either locally or via ssh).\n\nThe status of the push is output in tabular form, with each line representing the status of a\nsingle ref. Each line is of the form:\n\n<flag> <summary> <from> -> <to> (<reason>)\n\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\n\nThe status of up-to-date refs is shown only if --porcelain or --verbose option 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 values of the ref in a\nform suitable for using as an argument to git log (this is <old>..<new> in most cases,\nand <old>...<new> for forced 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 not a fast-forward\nand you did not force the update.\n\nremote rejected\nThe remote end refused the update. Usually caused by a hook on the remote side, or\nbecause the remote repository has one of the following safety options in effect:\nreceive.denyCurrentBranch (for pushes to the checked out branch),\nreceive.denyNonFastForwards (for forced non-fast-forward updates),\nreceive.denyDeletes or receive.denyDeleteCurrent. See git-config(1).\n\nremote failure\nThe remote end did not report the successful update of the ref, perhaps because of a\ntemporary error on the remote side, a break in the network connection, or other\ntransient error.\n\nfrom\nThe name of the local ref being pushed, minus its refs/<type>/ prefix. In the case of\ndeletion, the name of the local ref is omitted.\n\nto\nThe name of the remote ref being updated, minus its refs/<type>/ prefix.\n\nreason\nA human-readable explanation. In the case of successfully pushed refs, no explanation is\nneeded. For a failed ref, the reason for failure is described.\n",
            "subsections": []
        },
        "NOTE ABOUT FAST-FORWARDS": {
            "content": "When an update changes a branch (or more in general, a ref) that used to point at commit A to\npoint at another commit B, it is called a fast-forward update if and only if B is a\ndescendant of A.\n\nIn a fast-forward update from A to B, the set of commits that the original commit A built on\ntop of is a subset of the commits the new commit B builds on top of. Hence, it does not lose\nany history.\n\nIn contrast, a non-fast-forward update will lose history. For example, suppose you and\nsomebody else started at the same commit X, and you built a history leading to commit B while\nthe other person built a history leading to commit A. The history looks like this:\n\nB\n/\n---X---A\n\n\nFurther suppose that the other person already pushed changes leading to A back to the\noriginal repository from which you two obtained the original commit X.\n\nThe push done by the other person updated the branch that used to point at commit X to point\nat commit A. It is a fast-forward.\n\nBut if you try to push, you will attempt to update the branch (that now points at A) with\ncommit B. This does not fast-forward. If you did so, the changes introduced by commit A will\nbe lost, because everybody will now start building on top of B.\n\nThe command by default does not allow an update that is not a fast-forward to prevent such\nloss of history.\n\nIf you do not want to lose your work (history from X to B) or the work by the other person\n(history from X to A), you would need to first fetch the history from the repository, create\na history that contains changes done by both parties, and push the result back.\n\nYou can perform \"git pull\", resolve potential conflicts, and \"git push\" the result. A \"git\npull\" will create a merge commit C between commits A and B.\n\nB---C\n/   /\n---X---A\n\n\nUpdating A with the resulting merge commit will fast-forward and your push will be accepted.\n\nAlternatively, you can rebase your change between X and B on top of A, with \"git pull\n--rebase\", and push the result back. The rebase will create a new commit D that builds the\nchange between X and B on top of A.\n\nB   D\n/   /\n---X---A\n\n\nAgain, updating A with this commit will fast-forward and your push will be accepted.\n\nThere is another common situation where you may encounter non-fast-forward rejection when you\ntry to push, and it is possible even when you are pushing into a repository nobody else\npushes into. After you push commit A yourself (in the first picture in this section), replace\nit with \"git commit --amend\" to produce commit B, and you try to push it out, because forgot\nthat you have pushed A out already. In such a case, and only if you are certain that nobody\nin the meantime fetched your earlier commit A (and started building on top of it), you can\nrun \"git push --force\" to overwrite it. In other words, \"git push --force\" is a method\nreserved for a case where you do mean to lose history.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "",
            "subsections": [
                {
                    "name": "git push",
                    "content": "Works like git push <remote>, where <remote> is the current branch’s remote (or origin,\nif no remote is configured for the current branch).\n"
                },
                {
                    "name": "git push origin",
                    "content": "Without additional configuration, pushes the current branch to the configured upstream\n(branch.<name>.merge configuration variable) if it has the same name as the current\nbranch, and errors out without pushing otherwise.\n\nThe default behavior of this command when no <refspec> is given can be configured by\nsetting the push option of the remote, or the push.default configuration variable.\n\nFor example, to default to pushing only the current branch to origin use git config\nremote.origin.push HEAD. Any valid <refspec> (like the ones in the examples below) can be\nconfigured as the default for git push origin.\n"
                },
                {
                    "name": "git push origin :",
                    "content": "Push \"matching\" branches to origin. See <refspec> in the OPTIONS section above for a\ndescription of \"matching\" branches.\n"
                },
                {
                    "name": "git push origin master",
                    "content": "Find a ref that matches master in the source repository (most likely, it would find\nrefs/heads/master), and update the same ref (e.g.  refs/heads/master) in origin\nrepository with it. If master did not exist remotely, it would be created.\n"
                },
                {
                    "name": "git push origin HEAD",
                    "content": "A handy way to push the current branch to the same name on the remote.\n"
                },
                {
                    "name": "git push mothership master:satellite/master dev:satellite/dev",
                    "content": "Use the source ref that matches master (e.g.  refs/heads/master) to update the ref that\nmatches satellite/master (most probably refs/remotes/satellite/master) in the mothership\nrepository; do the same for dev and satellite/dev.\n\nSee the section describing <refspec>...  above for a discussion of the matching\nsemantics.\n\nThis is to emulate git fetch run on the mothership using git push that is run in the\nopposite direction in order to integrate the work done on satellite, and is often\nnecessary when you can only make connection in one way (i.e. satellite can ssh into\nmothership but mothership cannot initiate connection to satellite because the latter is\nbehind a firewall or does not run sshd).\n\nAfter running this git push on the satellite machine, you would ssh into the mothership\nand run git merge there to complete the emulation of git pull that were run on mothership\nto pull changes made on satellite.\n"
                },
                {
                    "name": "git push origin HEAD:master",
                    "content": "Push the current branch to the remote ref matching master in the origin repository. This\nform is convenient to push the current branch without thinking about its local name.\n"
                },
                {
                    "name": "git push origin master:refs/heads/experimental",
                    "content": "Create the branch experimental in the origin repository by copying the current master\nbranch. This form is only needed to create a new branch or tag in the remote repository\nwhen the local name and the remote name are different; otherwise, the ref name on its own\nwill work.\n"
                },
                {
                    "name": "git push origin :experimental",
                    "content": "Find a ref that matches experimental in the origin repository (e.g.\nrefs/heads/experimental), and delete it.\n"
                },
                {
                    "name": "git push origin +dev:master",
                    "content": "Update the origin repository’s master branch with the dev branch, allowing\nnon-fast-forward updates.  This can leave unreferenced commits dangling in the origin\nrepository.  Consider the following situation, 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 name, and so would be\nunreachable. As such, these commits would be removed by a git gc command on the origin\nrepository.\n"
                }
            ]
        },
        "SECURITY": {
            "content": "The fetch and push protocols are not designed to prevent one side from stealing data from the\nother repository that was not intended to be shared. If you have private data that you need\nto protect from a malicious peer, your best option is to store it in another repository. This\napplies to both clients and servers. In particular, namespaces on a server are not effective\nfor read access control; you should only grant read access to a namespace to clients that you\nwould trust with read 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 that are not\nexplicitly intended to be shared but can be used to optimize the transfer if the peer\nalso has them. The attacker chooses an object ID X to steal and sends a ref to X, but\nisn’t required to send the content of X because the victim already has it. Now the victim\nbelieves that the attacker has X, and it sends the content of X back to the attacker\nlater. (This attack is most straightforward for a client to perform on a server, by\ncreating a ref to X in the namespace the client has access to and then fetching it. The\nmost likely way for a server to perform it on a client is to \"merge\" X into a public\nbranch and hope that the user does additional work on this branch and pushes it back to\nthe server without noticing the merge.)\n\n2. As in #1, the attacker chooses an object ID X to steal. The victim sends an object Y that\nthe attacker already has, and the attacker falsely claims to have X and not Y, so the\nvictim sends Y as a delta against X. The delta reveals regions of X that are similar to Y\nto the attacker.\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\n\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": [
        "Works like git push <remote>, where <remote> is the current branch’s remote (or origin,",
        "if no remote is configured for the current branch).",
        "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.",
        "Push \"matching\" branches to origin. See <refspec> in the OPTIONS section above for a",
        "description of \"matching\" branches.",
        "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.",
        "A handy way to push the current branch to the same name on the remote.",
        "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.",
        "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.",
        "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.",
        "Find a ref that matches experimental in the origin repository (e.g.",
        "refs/heads/experimental), and delete it.",
        "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": [],
    "tldr": {
        "source": "official",
        "description": "Push commits to a remote repository.",
        "examples": [
            {
                "description": "Send local changes in the current branch to its default remote counterpart",
                "command": "git push"
            },
            {
                "description": "Send changes from a specific local branch to its remote counterpart",
                "command": "git push {{remote_name}} {{local_branch}}"
            },
            {
                "description": "Send changes from a specific local branch to its remote counterpart, and set the remote one as the default push/pull target of the local one",
                "command": "git push {{-u|--set-upstream}} {{remote_name}} {{local_branch}}"
            },
            {
                "description": "Send changes from a specific local branch to a specific remote branch",
                "command": "git push {{remote_name}} {{local_branch}}:{{remote_branch}}"
            },
            {
                "description": "Send changes on all local branches to their counterparts in a given remote repository",
                "command": "git push --all {{remote_name}}"
            },
            {
                "description": "Delete a branch in a remote repository",
                "command": "git push {{remote_name}} {{-d|--delete}} {{remote_branch}}"
            },
            {
                "description": "Remove remote branches that don't have a local counterpart",
                "command": "git push --prune {{remote_name}}"
            },
            {
                "description": "Publish tags that aren't yet in the remote repository",
                "command": "git push --tags"
            }
        ]
    }
}