]> git.ipfire.org Git - thirdparty/git.git/commit
push: new config option "push.autoSetupRemote" supports "simple" push
authorTao Klerks <tao@klerks.biz>
Fri, 29 Apr 2022 09:56:46 +0000 (09:56 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Apr 2022 18:20:55 +0000 (11:20 -0700)
commit05d57750c66e4b58233787954c06b8f714bbee75
tree5205a9e18538dfa9e205b3fee4f8806f74b10e2d
parent8a649be7e8010085a8a3f1c9126da5c02324350e
push: new config option "push.autoSetupRemote" supports "simple" push

In some "simple" centralized workflows, users expect remote tracking
branch names to match local branch names. "git push" pushes to the
remote version/instance of the branch, and "git pull" pulls any changes
to the remote branch (changes made by the same user in another place, or
by other users).

This expectation is supported by the push.default default option "simple"
which refuses a default push for a mismatching tracking branch name, and
by the new branch.autosetupmerge option, "simple", which only sets up
remote tracking for same-name remote branches.

When a new branch has been created by the user and has not yet been
pushed (and push.default is not set to "current"), the user is prompted
with a "The current branch %s has no upstream branch" error, and
instructions on how to push and add tracking.

This error is helpful in that following the advice once per branch
"resolves" the issue for that branch forever, but inconvenient in that
for the "simple" centralized workflow, this is always the right thing to
do, so it would be better to just do it.

Support this workflow with a new config setting, push.autoSetupRemote,
which will cause a default push, when there is no remote tracking branch
configured, to push to the same-name on the remote and --set-upstream.

Also add a hint offering this new option when the "The current branch %s
has no upstream branch" error is encountered, and add corresponding tests.

Signed-off-by: Tao Klerks <tao@klerks.biz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/push.txt
builtin/push.c
t/t5528-push-default.sh
transport.h