threads / discuss / 59386

git rebase issue

Subject: git rebase issue

## tl;dr

10 messages between Mar 13, 2023 and Mar 23, 2025.

replies: 9people: 4as markdown or json

Andy Shevchenko· Mar 13, 2023, 12:35 UTC · lore
Hi!

Recently Debian has updated the Git to 2.39.2 and broke my user case (I believe it's a problem in the Git itself and not Debian packaging or so).

So, my use case is to run
  git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase" "$branch"
in the repository that is made out of bare + a few worktrees.

Previously everything was working (my bare repository points to one of the existing branch: In shell prompt: ...(BARE:netboot)]$

With the new release I have got an error
  fatal: 'netboot' is already checked out at ...
To work around this I have to split the above to
  git checkout --ignore-other-worktrees "$branch"
  git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase"
which makes all these too inconvenient.
Any suggestions?
-- 
With Best Regards,
Andy Shevchenko
Andy Shevchenko· Mar 13, 2023, 12:58 UTC · re: Andy Shevchenko · lore

Re: git rebase issue

On Mon, Mar 13, 2023 at 2:35 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

Show 6 quoted lines
>
> Hi!
>
> Recently Debian has updated the Git to 2.39.2 and broke my user case
> (I believe it's a problem in the Git itself and not Debian packaging
> or so).

Forgot to add that last week it was working nicely (I don't remember the version, but according to Debian changelog it looks like 2.38.4 was working fine to me.

Show 22 quoted lines
> So, my use case is to run
>
>   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase" "$branch"
>
> in the repository that is made out of bare + a few worktrees.
>
> Previously everything was working (my bare repository points to one of
> the existing branch:
> In shell prompt: ...(BARE:netboot)]$
>
> With the new release I have got an error
>
>   fatal: 'netboot' is already checked out at ...
>
> To work around this I have to split the above to
>
>   git checkout --ignore-other-worktrees "$branch"
>   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase"
>
> which makes all these too inconvenient.
>
> Any suggestions?
-- 
With Best Regards,
Andy Shevchenko
Andy Shevchenko· Mar 20, 2023, 12:10 UTC · re: Andy Shevchenko · lore

Re: git rebase issue

On Mon, Mar 13, 2023 at 2:58 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

Show 35 quoted lines
> On Mon, Mar 13, 2023 at 2:35 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> >
> > Hi!
> >
> > Recently Debian has updated the Git to 2.39.2 and broke my user case
> > (I believe it's a problem in the Git itself and not Debian packaging
> > or so).
>
> Forgot to add that last week it was working nicely (I don't remember
> the version, but according to Debian changelog it looks like 2.38.4
> was working fine to me.
>
> > So, my use case is to run
> >
> >   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase" "$branch"
> >
> > in the repository that is made out of bare + a few worktrees.
> >
> > Previously everything was working (my bare repository points to one of
> > the existing branch:
> > In shell prompt: ...(BARE:netboot)]$
> >
> > With the new release I have got an error
> >
> >   fatal: 'netboot' is already checked out at ...
> >
> > To work around this I have to split the above to
> >
> >   git checkout --ignore-other-worktrees "$branch"
> >   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase"
> >
> > which makes all these too inconvenient.
> >
> > Any suggestions?

So, what should I do? Today I got again to help manually with my (used to working) scripts.

-- 
With Best Regards,
Andy Shevchenko
Felipe Contreras· Mar 20, 2023, 14:41 UTC · re: Andy Shevchenko · lore

Re: git rebase issue

On Mon, Mar 20, 2023 at 6:32 AM Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

Show 41 quoted lines
>
> On Mon, Mar 13, 2023 at 2:58 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Mon, Mar 13, 2023 at 2:35 PM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:
> > >
> > > Hi!
> > >
> > > Recently Debian has updated the Git to 2.39.2 and broke my user case
> > > (I believe it's a problem in the Git itself and not Debian packaging
> > > or so).
> >
> > Forgot to add that last week it was working nicely (I don't remember
> > the version, but according to Debian changelog it looks like 2.38.4
> > was working fine to me.
> >
> > > So, my use case is to run
> > >
> > >   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase" "$branch"
> > >
> > > in the repository that is made out of bare + a few worktrees.
> > >
> > > Previously everything was working (my bare repository points to one of
> > > the existing branch:
> > > In shell prompt: ...(BARE:netboot)]$
> > >
> > > With the new release I have got an error
> > >
> > >   fatal: 'netboot' is already checked out at ...
> > >
> > > To work around this I have to split the above to
> > >
> > >   git checkout --ignore-other-worktrees "$branch"
> > >   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase"
> > >
> > > which makes all these too inconvenient.
> > >
> > > Any suggestions?
>
> So, what should I do? Today I got again to help manually with my (used
> to working) scripts.
Do you have a sequence of steps to reproduce the issue?

With that it should be trivial to do `git bisect` and figure out which commit introduced the regression.

-- 
Felipe Contreras
Jeff King· Mar 20, 2023, 17:01 UTC · re: Andy Shevchenko · lore

Re: git rebase issue

[Please don't put random folks in the to/cc unless you think they have specific knowledge related to your problem.]

On Mon, Mar 20, 2023 at 02:10:38PM +0200, Andy Shevchenko wrote:
Show 15 quoted lines
> > > With the new release I have got an error
> > >
> > >   fatal: 'netboot' is already checked out at ...
> > >
> > > To work around this I have to split the above to
> > >
> > >   git checkout --ignore-other-worktrees "$branch"
> > >   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase"
> > >
> > > which makes all these too inconvenient.
> > >
> > > Any suggestions?
> 
> So, what should I do? Today I got again to help manually with my (used
> to working) scripts.

Running "git log --grep=already.checked.out" suggests that it may be b5cabb4a967 (rebase: refuse to switch to branch already checked out elsewhere, 2020-02-23).

Adding its author to the cc, who may be able to say more. But my understanding is that this was probably fixing a bug (though I don't know all the implications of having a branch checked out in multiple worktrees).

-Peff
Andy Shevchenko· Mar 20, 2023, 17:20 UTC · re: Jeff King · lore

Re: git rebase issue

On Mon, Mar 20, 2023 at 7:02 PM Jeff King <peff@peff.net> wrote:
> [Please don't put random folks in the to/cc unless you think they have
> specific knowledge related to your problem.]

Sorry about that, but my reaction was to the silence. I found your name is a top contributor, so that's why I have chosen your name.

Show 21 quoted lines
> On Mon, Mar 20, 2023 at 02:10:38PM +0200, Andy Shevchenko wrote:
>
> > > > With the new release I have got an error
> > > >
> > > >   fatal: 'netboot' is already checked out at ...
> > > >
> > > > To work around this I have to split the above to
> > > >
> > > >   git checkout --ignore-other-worktrees "$branch"
> > > >   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase"
> > > >
> > > > which makes all these too inconvenient.
> > > >
> > > > Any suggestions?
> >
> > So, what should I do? Today I got again to help manually with my (used
> > to working) scripts.
>
> Running "git log --grep=already.checked.out" suggests that it may be
> b5cabb4a967 (rebase: refuse to switch to branch already checked out
> elsewhere, 2020-02-23).
Thank you.

Indeed, reverting that (manually as it's a conflict with v2.40.0 current tree) fixes my issue.

> Adding its author to the cc, who may be able to say more. But my
> understanding is that this was probably fixing a bug (though I don't
> know all the implications of having a branch checked out in multiple
> worktrees).

Note, in my case it's "checked" in the BARE repository, which means it's actually not. This case shouldn't be an impediment or racy AFAIU.

-- 
With Best Regards,
Andy Shevchenko
Felipe Contreras· Mar 23, 2023, 20:37 UTC · re: Andy Shevchenko · lore

Re: git rebase issue

On Mon, Mar 20, 2023 at 12:11 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Mon, Mar 20, 2023 at 7:02 PM Jeff King <peff@peff.net> wrote:
Show 8 quoted lines
> > Adding its author to the cc, who may be able to say more. But my
> > understanding is that this was probably fixing a bug (though I don't
> > know all the implications of having a branch checked out in multiple
> > worktrees).
>
> Note, in my case it's "checked" in the BARE repository, which means
> it's actually not.
> This case shouldn't be an impediment or racy AFAIU.

In that case I agree it should work, but when I tried to reproduce the issue the bare repository is ignored, only worktrees are considered.

Are you sure the branch isn't checked out in other worktree(s)?
-- 
Felipe Contreras
Andy Shevchenko· Mar 24, 2023, 07:52 UTC · re: Felipe Contreras · lore

Re: git rebase issue

On Thu, Mar 23, 2023 at 10:38 PM Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 18 quoted lines
>
> On Mon, Mar 20, 2023 at 12:11 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Mon, Mar 20, 2023 at 7:02 PM Jeff King <peff@peff.net> wrote:
>
> > > Adding its author to the cc, who may be able to say more. But my
> > > understanding is that this was probably fixing a bug (though I don't
> > > know all the implications of having a branch checked out in multiple
> > > worktrees).
> >
> > Note, in my case it's "checked" in the BARE repository, which means
> > it's actually not.
> > This case shouldn't be an impediment or racy AFAIU.
>
> In that case I agree it should work, but when I tried to reproduce the
> issue the bare repository is ignored, only worktrees are considered.
>
> Are you sure the branch isn't checked out in other worktree(s)?
Yes. Since the commit was in v2.26 already, and I have noticed the
issue only recently, there are a few possibilities:
1) Debian is to slow to update a Git (doesn't sound like the case);
2) New version of the Git does something in the configuration files
that unveils the issue;
3) Something else I've been missing?

As for 2) I have found a new config.worktree which I tried to remove, nothing changed. Also I disabled extended worktree configuration in the main (~/.gitconfig) one. Didn't help either.

I have a bare repo with a Linux kernel and two worktrees. The HEAD in the bare points out to one of the branches which I try to rebase.

BARE:xxx (as shown by Git prompt helper in the Bash)
`git rebase -X ours --onto "vN+1" "vN" xxx` fails.
-- 
With Best Regards,
Andy Shevchenko
Andy Shevchenko· Mar 22, 2025, 13:42 UTC · re: Jeff King · lore

Re: git rebase issue

On Mon, Mar 20, 2023 at 7:02 PM Jeff King <peff@peff.net> wrote:
Show 26 quoted lines
> On Mon, Mar 20, 2023 at 02:10:38PM +0200, Andy Shevchenko wrote:
>
> > > > With the new release I have got an error
> > > >
> > > >   fatal: 'netboot' is already checked out at ...
> > > >
> > > > To work around this I have to split the above to
> > > >
> > > >   git checkout --ignore-other-worktrees "$branch"
> > > >   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase"
> > > >
> > > > which makes all these too inconvenient.
> > > >
> > > > Any suggestions?
> >
> > So, what should I do? Today I got again to help manually with my (used
> > to working) scripts.
>
> Running "git log --grep=already.checked.out" suggests that it may be
> b5cabb4a967 (rebase: refuse to switch to branch already checked out
> elsewhere, 2020-02-23).
>
> Adding its author to the cc, who may be able to say more. But my
> understanding is that this was probably fixing a bug (though I don't
> know all the implications of having a branch checked out in multiple
> worktrees).

FWIW, the last couple of versions (since I was not updating Git from the sources too often, usually once per half a year or so, I don't know the exact version which fixes it to me, and I don't want spend time to find that, because it works :) of Git seem to work properly to me. Thank you to everyone who made that happen!

-- 
With Best Regards,
Andy Shevchenko
Eric Sunshine· Mar 23, 2025, 01:37 UTC · re: Andy Shevchenko · lore

Re: git rebase issue

On Sat, Mar 22, 2025 at 9:43 AM Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

Show 18 quoted lines
> On Mon, Mar 20, 2023 at 7:02 PM Jeff King <peff@peff.net> wrote:
> > On Mon, Mar 20, 2023 at 02:10:38PM +0200, Andy Shevchenko wrote:
> > > > > With the new release I have got an error
> > > > >   fatal: 'netboot' is already checked out at ...
> > > > > To work around this I have to split the above to
> > > > >   git checkout --ignore-other-worktrees "$branch"
> > > > >   git rebase --rebase-merges -X ours --onto "$newbase" "$oldbase"
> > > > > which makes all these too inconvenient.
> >
> > Running "git log --grep=already.checked.out" suggests that it may be
> > b5cabb4a967 (rebase: refuse to switch to branch already checked out
> > elsewhere, 2020-02-23).
>
> FWIW, the last couple of versions (since I was not updating Git from
> the sources too often, usually once per half a  year or so, I don't
> know the exact version which fixes it to me, and I don't want spend
> time to find that, because it works :) of Git seem to work properly to
> me. Thank you to everyone who made that happen!

This was very likely fixed by 78a95e0d80 (worktree: detect from secondary worktree if main worktree is bare, 2025-02-05); see [1].

Regarding the attempt you cited in [2] in which you removed config.worktree and disabled extensions.worktreeConfig, I suspect the reason you didn't see any change in behavior is because you didn't re-add "core.bare=true" to <repo>.git/config.

[1]: https://lore.kernel.org/git/pull.1829.v4.git.1738737014194.gitgitgadget@gmail.com/ [2]: https://lore.kernel.org/git/CAHp75VfSdth4B-oW8JCt4kBkehu6+B9ueQAJL1g99Ev3RiMKoQ@mail.gmail.com/

← back to recent threads