Git Reference ยท Configuration Options
push.default and push.autoSetupRemote settings
Reference for push.default, push.autoSetupRemote, push.followTags and push.useForceIfIncludes: decide what a bare git push sends and how upstreams are set.
When you run git push with no arguments, Git must decide which branches to send and where. push.default answers the "which branches" question, and push.autoSetupRemote removes the need for -u on the first push of a new branch.
The default value, simple, is deliberately cautious: it pushes the current branch to a branch of the same name on its upstream and refuses when the names differ.
git config --global push.default simple git config --global push.autoSetupRemote true git config --global push.followTags true
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git config push.default (nothing | current | upstream | tracking | simple | matching) git config push.autoSetupRemote (true | false) git config push.followTags (true | false) git config push.useForceIfIncludes (true | false) git config push.gpgSign (true | false | if-asked) git config push.recurseSubmodules (check | on-demand | only | no)
| Name | Description |
|---|---|
push.default = simple |
Default. Push the current branch to the same-named branch on its upstream; refuse if the names differ or no upstream exists (triangular setups use the same name). |
push.default = current |
Push the current branch to a branch of the same name, creating it if needed. |
push.default = upstream |
Push to the configured upstream branch, whatever its name (tracking is the old name). |
push.default = matching |
Push every local branch that has a same-named branch on the remote. Legacy; risky. |
push.default = nothing |
Refuse to push without an explicit refspec. |
push.autoSetupRemote |
When the branch has no upstream, a plain git push behaves like git push -u origin <branch> (Git 2.37+). |
push.followTags |
Also push annotated tags that point at commits being pushed. |
push.useForceIfIncludes |
Makes --force-with-lease stricter by checking that you integrated the remote tip first. |
push.gpgSign |
Sign pushes (needs server support). |
Errors: a new branch without an upstream fails with fatal: The current branch topic has no upstream branch. and a hint showing git push --set-upstream. With simple, a differently named upstream fails with a message explaining that names do not match.
Usage notes
- Which remote?
push.defaultonly picks branches. The remote comes frombranch.<name>.pushRemote, thenremote.pushDefault, then the branch'sremote, thenorigin. autoSetupRemoteis the quality-of-life setting for topic-branch workflows: the first push creates the upstream, sogit statusand later pulls work immediately.- Avoid
matching. It dates from Git 1.x and can publish half-finished branches;simplereplaced it as the default in Git 2.0. followTagsskips lightweight tags, as the demo shows; push those explicitly withgit push origin <tag>.- Force pushes are not controlled here: use
--force-with-lease, and see thegit pushpage for details. - Explicit refspecs ignore
push.default.git push origin mainalways sends exactly what you named. - Mirrors:
remote.<name>.pushrefspecs, if set, also take precedence overpush.default.
Related
git push,branch.*,pull.rebase,git tag- Lessons: Push and pull, Remotes