When I have a branch that I’m sharing only between myself, it’s occasionally helpful to force push and then reset all the other repo versions of the branch to the new one. Yes, I know that’s inherently dangerous, and I’ve screwed up doing this a couple times.
Here’s one way to do it:
When I do this, I always first check that the branch on the repo in question is pushed to the upstream branch (i.e., I can consider the current state discardable), and sometimes I’ll also do a sanity check diff against the commit hash that came with the fetch to see what I’m going to get with the reset.
Assuming that I still want to be stupid and dangerous, is there an easier way to do it?
I asked Grok if there was an short cut for this action, and as expected, there’s a nice one:
Here the @{u} is a shorthand for the current upstream branch.
Grok suggested a one liner using && for the two commands, but when I’m being dangerous and (possibly) stupid I’d rather be more deliberate and do these separately, so that I can think between the two steps.
code
more code
~~~~