Re: [RFC] reset --hard: warn before discarding staged content with no commit history
- From
- Koutsouflakis Stefanos <koutsouflakis.stefanos@proton.me>
- Date
- Dec 11, 2025, 11:53 UTC
- Message-ID
- <0lbeTWjDGq8hINMi-lj65HLgAIlUNZe_tzANStd9xxHQqAyZaEnaA0yPzVeY_VcReQIKNjY7eBEUGwMGvlbZ-0W0QZpux22cIHnosa0eX_k=@proton.me>
- In-Reply-To
- <xmqqldj9g0pj.fsf@gitster.g>
On Wed, Dec 10, 2025 at 10:24 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Koutsouflakis Stefanos <koutsouflakis.stefanos@proton.me> writes: > > When running "git reset --hard" in a repository where staged > > content has never been committed, the staged files are lost. This > > seems like a case where requiring --force could be helpful. > > The thinking has always been "'--hard' means what it says! HARD > removes things harder than other modes---there is need to add > '--force' to it".
I agree that "--hard" conveys serious intent. But I would argue there is a meaningful difference between "lose your uncommitted changes" and "lose your entire project".
To be clear, I'm addressing a very narrow scenario: the user has run init on an existing codebase, staged files with git add, but has not yet made a first commit. Running reset --hard at this point destroys the entire project with no realistic recovery path. This is almost certainly never intentional.
Thanks, Stefanos