Skip to content

Commit 433fef1

Browse files
committed
doc: git-push: clarify "what to push"
- Be more explicit about what we're describing ("which branches" instead of "what to push") - Split out the ways to specify which branches into a numbered list, since there are 5 different ways to specify it and it's a lot to parse in paragraph form - The explanation of "push.default=simple" is confusing to some users, use an explanation more similar to the one in `man git-config` - Mention the most common case where push.default=simple is likely to fail, and how to handle it Signed-off-by: Julia Evans <[email protected]>
1 parent b22840d commit 433fef1

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Documentation/git-push.adoc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ argument (for example `git push dev`), then if that's not specified the
2727
`branch.*.remote` configuration for the current branch, and then defaults
2828
to `origin`.
2929

30-
When the command line does not specify what to push with `<refspec>...`
31-
arguments or `--all`, `--mirror`, `--tags` options, the command finds
32-
the default `<refspec>` by consulting `remote.*.push` configuration,
33-
and if it is not found, honors `push.default` configuration to decide
34-
what to push (See linkgit:git-config[1] for the meaning of `push.default`).
30+
To decide which branches, tags, or other refs to push, Git uses
31+
(in order of precedence):
32+
33+
1. The `<refspec>` argument(s) (for example `main` in `git push origin main`)
34+
or the `--all`, `--mirror`, or `--tags` options
35+
2. The `remote.*.push` configuration for the current branch
36+
3. The `push.default` configuration (See linkgit:git-config[1] for
37+
the meaning of `push.default`).
3538
3639
When neither the command-line nor the configuration specifies what to
37-
push, the default behavior is used, which corresponds to the `simple`
38-
value for `push.default`: the current branch is pushed to the
39-
corresponding upstream branch, but as a safety measure, the push is
40-
aborted if the upstream branch does not have the same name as the
41-
local one.
40+
push, the current branch is pushed to the branch with the same name
41+
on the remote. The current branch must have a configured upstream with
42+
the same name, so this will fail when pushing a new branch.
43+
You can run `git push -u <repository> <current-branch>`
44+
to configure the upstream.
4245

4346
You can make interesting things happen to a repository
4447
every time you push into it, by setting up 'hooks' there. See

0 commit comments

Comments
 (0)