Skip to content

pr-git-1570/perk11/diverging-advice-improvements-v1

From: Konstantin Pereiaslov <perk11@perk11.info>

Added a description of what the offered options will do and for pull
also offered a 3rd option during a pull - a hard reset.
This option should be helpful for the new users that accidentally
committed into the wrong branch which is a scenario I saw very
often.

The resulting tooltip looks like this for pull:

hint: Diverging branches can't be fast-forwarded.
Consider the following options:
hint:
hint: To merge remote changes into your branch:
hint:   git merge --no-ff
hint:
hint: To apply your changes on top of remote changes:
hint:   git rebase
hint:
hint: To discard your local changes and apply the remote changes:
hint:   git reset --hard refs/remotes/upstream/branch-name
hint:
hint: Disable this message with "git config advice.diverging false"

There is some danger because it's semi-destructive, but so are
other options offered if user doesn't know the commands to
revert back. Additionally, I think "To discard your local changes"
wording describes the danger clearly enough.

And for merge I improved the wording and added a description of what
the commands do:

hint: Diverging branches can't be fast-forwarded.
hint: Consider the following options:
hint:
hint: To merge changes into your branch:
hint:   git merge --no-ff
hint:
hint: To apply your changes on top:
hint:   git rebase
hint:
hint: Disable this message with "git config advice.diverging false"

Signed-off-by: Konstantin Pereiaslov <perk11@perk11.info>

Submitted-As: https://lore.kernel.org/git/pull.1570.git.git.1693861162353.gitgitgadget@gmail.com
Assets 2