git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] pull: add --hard mode

From
Artur Bieniek <abieniek@antmicro.com>
Date
Aug 20, 2026, 16:43 UTC
Message-ID
<2b9cc581-7c8e-4cb3-9524-2b466209ac7e@antmicro.com>
In-Reply-To
<xmqqo6ewsrzd.fsf@gitster.g>

One case where --ff-only does not seem to cover that audience is when the upstream branch itself is rewritten.

For example, a checkout may contain no local development at all and only be used to track the latest state of an upstream branch, but if that branch is rebased or otherwise force-updated, git pull --ff-only will refuse to update it because the histories have diverged.

That seems like a reasonably natural use case for the behavior Phillip described: git pull --reset on a clean working tree would mean "make this checkout match the fetched upstream", while still refusing by default to discard uncommitted changes.

I also like that distinction better than my original --hard proposal, since the destructive working-tree behavior would no longer be implicit in the primary option.

Thanks, Artur

On 8/20/26 5:59 PM, Junio C Hamano wrote:
Show 31 quoted lines
> Phillip Wood <phillip.wood123@gmail.com> writes:
> 
>> I think if the design was slightly different so that it errored out by
>> default if there were uncommitted changes then that would make it worth
>> while as it is safer than "git fetch; git reset --hard @{u}" and would
>> allow the user to carry over those changes with "--autostash". So to me
>> something like
>>
>> 	git pull --reset [--discard-changes | --autostash]
>>
>> would be a more convincing design.
>> ...
>> If it refused to reset by default when there were uncommitted changes
>> would that be safe enough? Uncommitted changes would be protected and
>> any local commits that become unreachable after the reset can still be
>> retrieved from the reflog. It's not quite the same as integrating remote
>> and local changes, but more like updating the working copy.
> 
> Yup, but git pull --ff-only serves the "No development is done in
> this repository; it is merely to keep the latest sources here"
> audience just fine.
> 
> What you are suggesting may be *useful* for those who agree with
> this statement:
> 
>      I do value my local changes because I haven't committed them,
>      but I am willing to discard these changes and replace them with
>      whatever the upstream did.
> 
> but I am not sure of the use case for a repository/working tree
> that is managed in such a way.
Previous: Junio C HamanoNext: Kristoffer Haugsbakk
Message 5 of 9 in “pull: add --hard mode”
  1. pull: add --hard modeArtur Bieniek via GitGitGadget, Aug 18, 2026
  2. Junio C HamanoAug 18, 2026
  3. Phillip WoodAug 20, 2026
  4. Junio C HamanoAug 20, 2026
  5. Artur BieniekAug 20, 2026
  6. Kristoffer HaugsbakkAug 20, 2026
  7. Artur BieniekAug 24, 2026
  8. Junio C HamanoAug 24, 2026
  9. Junio C HamanoAug 21, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.