@@ -19,30 +19,35 @@ SYNOPSIS
19
19
DESCRIPTION
20
20
-----------
21
21
22
- Updates remote refs using local refs, while sending objects
23
- necessary to complete the given refs.
22
+ Updates one or more branches, tags, or other references in a remote
23
+ repository from your local repository, and sends all necessary data
24
+ that isn't already on the remote.
24
25
25
- You can make interesting things happen to a repository
26
- every time you push into it, by setting up 'hooks' there. See
27
- documentation for linkgit:git-receive-pack[1].
26
+ The simplest way to push is `git push <remote> <branch>` .
27
+ `git push origin main` will push the local `main` branch to the `main`
28
+ branch on the remote named `origin` .
29
+
30
+ The `<repository>` argument defaults to the upstream for the current branch,
31
+ or `origin` if there's no configured upstream.
28
32
29
- When the command line does not specify where to push with the
30
- `<repository>` argument, `branch.*.remote` configuration for the
31
- current branch is consulted to determine where to push. If the
32
- configuration is missing, it defaults to 'origin' .
33
+ To decide which branches, tags, or other refs to push, Git uses
34
+ (in order of precedence):
33
35
34
- When the command line does not specify what to push with `<refspec>...`
35
- arguments or `--all` , `--mirror` , `--tags` options, the command finds
36
- the default `<refspec>` by consulting `remote.*.push` configuration,
37
- and if it is not found, honors `push.default` configuration to decide
38
- what to push (See linkgit:git-config[1] for the meaning of `push.default` ).
36
+ 1. The `<refspec>` argument(s) (for example `main` in `git push origin main` )
37
+ or the `--all` , `--mirror` , or `--tags` options
38
+ 2. The `remote.*.push` configuration for the repository being pushed to
39
+ 3. The `push.default` configuration. The default is `push.default=simple` ,
40
+ which will push to a branch with the same name as the current branch.
41
+ See the <<CONFIGURATION,CONFIGURATION>> section below for more on `push.default` .
39
42
40
- When neither the command-line nor the configuration specifies what to
41
- push, the default behavior is used, which corresponds to the `simple`
42
- value for `push.default` : the current branch is pushed to the
43
- corresponding upstream branch, but as a safety measure, the push is
44
- aborted if the upstream branch does not have the same name as the
45
- local one.
43
+ `git push` may fail if you haven't set an upstream for the current branch,
44
+ depending on what `push.default` is set to.
45
+ See the <<UPSTREAM-BRANCHES,UPSTREAM BRANCHES>> section below for more
46
+ on how to set and use upstreams.
47
+
48
+ You can make interesting things happen to a repository
49
+ every time you push into it, by setting up 'hooks' there. See
50
+ documentation for linkgit:git-receive-pack[1].
46
51
47
52
48
53
OPTIONS[[OPTIONS]]
@@ -710,8 +715,8 @@ a `git gc` command on the origin repository.
710
715
711
716
include::transfer-data-leaks.adoc[]
712
717
713
- CONFIGURATION
714
- -------------
718
+ CONFIGURATION[[CONFIGURATION]]
719
+ ------------------------------
715
720
716
721
include::includes/cmd-config-section-all.adoc[]
717
722
0 commit comments