Skip to content

remote: qualify "git pull" advice for non-upstream branches#2301

Open
HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:status-pull-advice-qualified
Open

remote: qualify "git pull" advice for non-upstream branches#2301
HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:status-pull-advice-qualified

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented May 12, 2026

Copy link
Copy Markdown
Contributor
  • Don't suggest git pull when we have no good command to suggest.
  • New test for this. Asserts the behind line shows with no follow-up advice.

@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

/submit

@gitgitgadget-git

Copy link
Copy Markdown

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v1

To fetch this version to local tag pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v1

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 285e94e.

@HaraldNordgren HaraldNordgren force-pushed the status-pull-advice-qualified branch 2 times, most recently from e5e312d to 1f06873 Compare May 13, 2026 09:48
@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

/submit

@gitgitgadget-git

Copy link
Copy Markdown

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v2

To fetch this version to local tag pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v2

@gitgitgadget-git

Copy link
Copy Markdown

This branch is now known as hn/status-pull-advice-qualified.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via d66a25f.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 53bf69b.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 577f599.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "New Topics" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Comments?
source: <[email protected]>

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 4887a94.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 4b48622.

@gitgitgadget-git

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Harald Nordgren via GitGitGadget" <[email protected]> writes:

> From: Harald Nordgren <[email protected]>
>
> When "git status" reports the local branch is behind the push
> branch, the advice suggested a bare "git pull". That follows the
> upstream, which may live on a different remote, so emit
> "git pull <remote> <branch>" instead.

Hmph, shouldn't this be done conditionally, though?  Most new users
follow the recommended pattern to set branch.<name>.merge so that
"git pull" would do the right thing for them, I presume, even when
they are using triangular workflow to push to a different remote
than the remote they pull from, so the new and more verbose message
would not help the users any more than the existing message, right?

Can the code tell the situation where the extra part of the message
would help and give it only then?

@HaraldNordgren HaraldNordgren force-pushed the status-pull-advice-qualified branch 4 times, most recently from d9e3519 to 3703be9 Compare May 19, 2026 19:07
@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 66404e5.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Comments?
source: <[email protected]>

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via e799159.

@gitgitgadget-git

Copy link
Copy Markdown

Harald Nordgren wrote on the Git mailing list (how to reply to this email):

> Hmph, shouldn't this be done conditionally, though?  Most new users
> follow the recommended pattern to set branch.<name>.merge so that
> "git pull" would do the right thing for them, I presume, even when
> they are using triangular workflow to push to a different remote
> than the remote they pull from, so the new and more verbose message
> would not help the users any more than the existing message, right?
>
> Can the code tell the situation where the extra part of the message
> would help and give it only then?

Yes, that's a good idea.


Harald

@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

/submit

@gitgitgadget-git

Copy link
Copy Markdown

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v4

To fetch this version to local tag pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v4:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2301/HaraldNordgren/status-pull-advice-qualified-v4

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 8961089.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Comments?
source: <[email protected]>

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 7c5026e.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 134dd16.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via c7f6469.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 8a4a02a.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Comments?
source: <[email protected]>

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via c1693bf.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Comments?
source: <[email protected]>

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via f9f5309.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via c7be48c.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 629fe44.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 7842d56.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 1291dbe.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Comments?
source: <[email protected]>

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via cbbe75f.

@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via d42fc68.

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Comments?
source: <[email protected]>

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Comments?
source: <[email protected]>

Enable ENABLE_ADVICE_PULL for push-branch comparisons too, not just
the upstream entry, so the "use git pull" hint prints when the local
branch is behind its push branch.

Spell out "git pull <remote> <branch>" so running the suggested
command actually pulls the ref the user was told about; plain
"git pull" would fetch the upstream instead.

Do not suggest "git pull" when we have no good command to suggest.

Signed-off-by: Harald Nordgren <[email protected]>
@gitgitgadget-git

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Harald Nordgren via GitGitGadget" <[email protected]> writes:

> From: Harald Nordgren <[email protected]>
>
> Enable ENABLE_ADVICE_PULL for push-branch comparisons too, not just
> the upstream entry, so the "use git pull" hint prints when the local
> branch is behind its push branch.
>
> Spell out "git pull <remote> <branch>" so running the suggested
> command actually pulls the ref the user was told about; plain
> "git pull" would fetch the upstream instead.
>
> Signed-off-by: Harald Nordgren <[email protected]>
> ---
>     remote: qualify "git pull" advice for non-upstream branches
>     
>      * Don't suggest git pull when we have no good command to suggest.
>      * New test for this. Asserts the behind line shows with no follow-up
>        advice.

Very well written.  

What does not happen in the "punt" case (the first bullet point
above) may deserve to be given in the commit log message, but
otherwise it is very clear what the change wanted to do to the
future readers of "git log".  

>  remote.c                 |  48 +++++++++++++++----
>  t/t6040-tracking-info.sh | 100 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 140 insertions(+), 8 deletions(-)

The code changes look correct, and the new tests checks the new
suggestion as well as the "punt" case, which is good.

Shall we mark it for 'next' now?

Thanks for working on this.

>> diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
> index 0242b5bf7a..91cbb8775d 100755
> --- a/t/t6040-tracking-info.sh
> +++ b/t/t6040-tracking-info.sh
> @@ -646,4 +646,104 @@ test_expect_success 'status.compareBranches with remapped push and upstream remo
>  	test_cmp expect actual
>  '
>  
> +test_expect_success 'status.compareBranches behind both upstream and push' '
> +	test_config -C test push.default current &&
> +	test_config -C test remote.pushDefault origin &&
> +	test_config -C test status.compareBranches "@{upstream} @{push}" &&
> +	git -C test checkout -b feature13 upstream/main &&
> +	(cd test && advance work13) &&
> +	git -C test push origin &&
> +	git -C test branch --set-upstream-to upstream/ahead &&
> +	git -C test reset --hard HEAD^ &&
> +	git -C test status >actual &&
> +	cat >expect <<-EOF &&
> +	On branch feature13
> +	Your branch is behind ${SQ}upstream/ahead${SQ} by 1 commit, and can be fast-forwarded.
> +	  (use "git pull" to update your local branch)
> +
> +	Your branch is behind ${SQ}origin/feature13${SQ} by 1 commit, and can be fast-forwarded.
> +	  (use "git pull origin feature13" to update your local branch)
> +
> +	nothing to commit, working tree clean
> +	EOF
> +	test_cmp expect actual
> +'

A good test that clearly shows how @{push} is described ;-)

> +test_expect_success 'status.compareBranches with remapped push and behind push branch' '
> +	test_config -C test remote.pushDefault origin &&
> +	test_config -C test remote.origin.push refs/heads/feature14:refs/heads/remapped14 &&
> +	test_config -C test status.compareBranches "@{push}" &&
> +	git -C test checkout -b feature14 upstream/main &&
> +	(cd test && advance work14) &&
> +	git -C test push &&
> +	git -C test reset --hard HEAD^ &&
> +	git -C test status >actual &&
> +	cat >expect <<-EOF &&
> +	On branch feature14
> +	Your branch is behind ${SQ}origin/remapped14${SQ} by 1 commit, and can be fast-forwarded.
> +	  (use "git pull origin remapped14" to update your local branch)
> +
> +	nothing to commit, working tree clean
> +	EOF
> +	test_cmp expect actual
> +'

OK.

@HaraldNordgren HaraldNordgren force-pushed the status-pull-advice-qualified branch from ef54dac to 87d63f0 Compare June 10, 2026 17:31
@gitgitgadget-git

Copy link
Copy Markdown

Harald Nordgren wrote on the Git mailing list (how to reply to this email):

> >     remote: qualify "git pull" advice for non-upstream branches
> >
> >      * Don't suggest git pull when we have no good command to suggest.
> >      * New test for this. Asserts the behind line shows with no follow-up
> >        advice.
>
> Very well written.
>
> What does not happen in the "punt" case (the first bullet point
> above) may deserve to be given in the commit log message, but
> otherwise it is very clear what the change wanted to do to the
> future readers of "git log".

Thanks. It's a good point, but maybe it's implicit that nothing
happens when nothing can happen?

> Shall we mark it for 'next' now?
>
> Thanks for working on this.

Yes please, thanks for all the help!


Harald

@gitgitgadget-git

Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/status-pull-advice-qualified on the Git mailing list:

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

Will merge to 'next'?
cf. <[email protected]>
source: <[email protected]>

@gitgitgadget-git

Copy link
Copy Markdown

This patch series is no longer integrated into seen.

@gitgitgadget-git gitgitgadget-git Bot removed the seen label Jun 12, 2026
@gitgitgadget-git

Copy link
Copy Markdown

This patch series was integrated into seen via 1f3cfd2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant