Hi Steven, forgive the incoming question if it appears rude (I am
genuinely curious):
On Mon, Nov 23, 2026 at 4:00 PM Steven Rostedt <rost…@goodmis.org> wrote:
>
> On Fri, 20 Nov 2026 22:09:32 +0100
> Mirko Faina <mro…@delayed.space> wrote:
>
> > You could just reset without the --hard option and restore what you
> > don't want to keep. Otherwise there's the --keep option that aborts the
> > reset if there's local changes, but you'd have to remember to type it
> > out every time.
>
> I just tried it without the --hard and it reminded me why I never use that.
>
> I just wanted to update one of my branches to one of my devel branches and
> did a git reset without the hard and at the end it gives me:
[a large diff between HEAD and working tree]
Here a simple "git restore ." would restore the working tree to match
the index (which should be equivalent to HEAD), right?
I confess I'm very confused about why you use reset to update a branch
in the first place: you also wrote
> The reason I use git reset --hard is because I work on several topic
> branches and create development ones all the time. Sometimes I add commits
> across branches. I'll create a temp branch and work on it until I like it
> and then copy the sha1 of that branch, checkout the branch I want to use,
> and do a "git reset --hard sha1" to convert the actual branch to the temp
> one.
It seems to me you could instead do
git switch -c temp <some-useful-base>
… work, commit …
git switch branch-i-care-about
git merge temp
and edit the commit message as needed, or replace the merge with "git
cherry-pick ..temp" (or rebase "temp" before merging) if you prefer a
(simulated) fast-forward.
On the other hand, you could also do "git branch -f
branch-i-care-about temp", with the same kinds of "force flags can
lose work" caveats, though at least in that case you only risk losing
the commits referred to by branch-i-care-about@{1} when the GC runs
(as opposed to potentially losing uncommitted work with reset).
So, have you not considered those options? Or have you, and what about
them is unsuitable compared to git-reset? (Yes, I know the document
point of git-reset is to "Set 'HEAD' or the index to a known state,"
so it's not totally out of the ordinary to use it to set a branch
[HEAD] to another branch [known state], but I find the pattern a bit
odd.)
--
D. Ben Knoble