]> git.99rst.org Git - git.git/commit
push: suggest <remote> <branch> for a slash slip
authorHarald Nordgren <redacted>
Sat, 27 Jun 2026 18:02:25 +0000 (18:02 +0000)
committerJunio C Hamano <redacted>
Sun, 28 Jun 2026 02:36:43 +0000 (19:36 -0700)
commita85a43c4802c124a504c42c63129a97d7f8346c1
tree55b46547cd10d366b6425be925d70242728685eb
parent2faf0f0256cbf4cef447202276ca57d36e1d9380
push: suggest <remote> <branch> for a slash slip

When pushing the 'main' branch to the remote 'origin', i.e.,

    $ git push origin main

it is easy to mistakenly write

    $ git push origin/main

That is parsed as the repository to push to, and since 'origin/main'
is neither a configured remote nor a path it dies with:

    fatal: 'origin/main' does not appear to be a git repository

Often 'origin/main' does not exist as a repository, so the command
fails without doing any harm, but it gives no hint that a space was
meant instead of a slash and can leave the user puzzled.

When the argument is not an existing path or configured remote but
its part before the first slash names one, suggest the intended
'<remote> <branch>' form:

    $ git push origin main

The suggestion is shown as advice so it can be silenced with
advice.pushRepoLooksLikeRef.

Signed-off-by: Harald Nordgren <redacted>
Signed-off-by: Junio C Hamano <redacted>
Documentation/config/advice.adoc
advice.c
advice.h
builtin/push.c
t/t5529-push-errors.sh
git clone https://git.99rst.org/PROJECT