Re: [RFC] git-brebase
- From
- Nico Williams <nico@cryptonector.com>
- Date
- Oct 3, 2026, 21:13 UTC
- Message-ID
- <asFv9QcpLgzPnnFb@ubby>
- In-Reply-To
- <asFoq4gnl1caJM2U@debian>
On Sat, Oct 03, 2026 at 10:56:25PM +0200, Alejandro Colomar wrote:
Show 8 quoted lines
> > I also have a getopts_long-like function (see my gists) for bash if you > > like. > > I think getopts(1) is not usable for git(1)-related scripts, because > getopts(1) interprets '--' as the end of the options, but git(1) uses it > for distinguishing commits from paths. If anyone shows me how it can be > used, I'd be interested, because I've hit this issue in the past with > other script.
https://gist.github.com/nicowilliams/f3fe2b10b380aecdef403acb246dced2
Though there's many ways to do this.
Show 10 quoted lines
> > > cat >"$callback" <<__EOF__ > > > #!/bin/bash > > > ... > > > __EOF__ > > > chmod +x "$callback"; > > > > Here what might be better is to have a command-line option to execute > > this callback without having to write it to a file, > > How would you do it?
I'd have an option or sub-command of the main script that says "do the callback thing", then when you run `git bisect run ...` put in the name of this script as the command and the "do the callback thing" option next.
Show 5 quoted lines
> > and use environment > > variables to pass arguments to it. > > The callback doesn't really need any arguments, since 'git bisect run' > won't pass any arguments to it.
But you're embedding values into the temp executable script -- if you don't have that any more you'll have to pass those in.
> > which means I can't use this in detached HEAD mode :( > > Oh! I wasn't aware that git-rebase(1) supported detached HEAD mode.
Sure does!
Show 6 quoted lines
> > I work in detached HEAD mode almost exclusively. I know, that's.. > > weird. But it works for me. > > Ouch! Indeed. :) > Out of curiosity, are there any interesting reasons for such > self-implied pain?
I often do:
: ; git checkout origin/master : ; <do some work> : ; git add ...; git commit -m '...' : ; git push myfork HEAD:refs/heads/the-branch-name-here # <-- I name it here
then open a PR.
Now I don't have a branch here, but who cares? If I switch to other work and later want to come back to this work I'll either a) create a local branch then, and/or b) when I resume work on the first thing I'll `git checkout myfork/the-branch-name-here` and... once more work in detached HEAD mode.
And if I need to see "what was I doing?" then I use `git log --oneline` and `git reflog` and I quickly see the remote branch of interest.
The remote branches are the symbolic names I need to preserve, and my clone will know them, so I only need local branch names for things I work on w/o a network or over a long time.
I do exaggerate a bit. I do this a lot, but maybe not quite "almost exclusively". Often I'm forced to have a local branch by opinionated tools other than git itself.
Nico