Fwd: Right way to make a store local changes to repos

From: Anton Saietskii <vsasjason_at_gmail.com>
Date: Wed, 18 Oct 2023 15:08:41 UTC
Hi folks,

Here's what I'm doing:
* "git clone .../ports.git"
* since there are some patches which will never hit main tree (like
ccache support in bsd.gecko.mk), "git checkout -b local"
* "git pull -r" when I'm on local, hacking, commits, pull again, ...
* if I need to make some patch and send it -- I do "git checkout -b
<feature>" from local and "diff"/"format-patch local" when ready, then
"git checkout local" back

To summarize:
origin/main -> main
local == I pull here, store local patches here
feature-X == creating from local, I do patches which I send back here

But sometimes, though not very often, I need to create a patch from a
clean tree (or switch to it for another reason), and here comes the
issue: "local" is up to date with "origin/main", but "main" is not.
Let's say it's 1000 commits behind (with only ~5 local ones), and
those commits changed 4000 files, so when I do "git checkout main" --
my working tree goes far away into the past, I'm getting 4000 writes
to files (instead of only 5 which I changed locally).
How can I avoid that, keeping local changes at the same time? Thanks in advance.

--
wbr,
Anton