Subject: Re: [PATCH 0/5] Advice on checkout dirty files

From: Phillip Wood <[email-masked]>
Date: Tue, 10 Mar 2026 10:33:13 +0000

Hi Arsh

On 10/03/2026 08:51, Arsh Srivastava via GitGitGadget wrote:
> This is my submission for microproject [GSOC]
> 
> This patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users
> when they attempt to switch branches with local modifications that would be
> overwritten by the operation.

If the intent is for the user to carry over the changes to the new 
branch then recommending "git checkout -m" might be more convenient 
rather than having to stash, checkout and unstash as three separate steps.

Something seems to have gone awry with your branch as there are other 
patches in this series. You should rebase your branch onto the upstream 
master branch with

     git rebase --onto origin/master HEAD^

and then when you push it double check how many commits there are in the 
summary of the pull request before submitting.

Thanks

Phillip

> The new advice follows the same patterns established by existing advice
> functions such as advise_on_updating_sparse_paths(). When triggered, it
> lists the affected files and suggests using git stash push/pop to save and
> restore local changes.
> 
> The advice can be silenced with:
> 
> git config set advice.stashBeforeCheckout false
> 
> Changes:
> 
>> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add
>> "stashBeforeCheckout" to advice_setting[] and implement
>> advise_on_checkout_dirty_files() function
>> Documentation/config/advice.adoc: document the new advice key
> 
> Signed-off-by: Arsh Srivastava [email-masked]
> 
> Arsh Srivastava (1):
>    advice: add stashBeforeCheckout advice for dirty branch switches
> 
> Junio C Hamano (1):
>    The 13th batch
> 
> K Jayatheerth (1):
>    repo: remove unnecessary variable shadow
> 
> LorenzoPegorari (2):
>    diff: handle ANSI escape codes in prefix when calculating diffstat
>      width
>    t4052: test for diffstat width when prefix contains ANSI escape codes
> 
>   Documentation/RelNotes/2.54.0.adoc | 14 +++++++++++++
>   Documentation/config/advice.adoc   |  5 +++++
>   advice.c                           | 27 +++++++++++++++++++++++++
>   advice.h                           |  2 ++
>   builtin/repo.c                     |  1 -
>   diff.c                             | 12 ++++-------
>   t/t4052-stat-output.sh             | 32 ++++++++++++++++++++++++++++++
>   7 files changed, 84 insertions(+), 9 deletions(-)
> 
> 
> base-commit: 3fe08b8fd1f7731edabeab8138547ec88d6407de
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v1
> Pull-Request: https://github.com/git/git/pull/2233