# git rebase issue

10 messages from 2023-03-13 to 2025-03-23. Participants: Andy Shevchenko, Felipe Contreras, Jeff King, Eric Sunshine.
Thread: https://gitlist.dev/t/59386

## Andy Shevchenko, 2023-03-13 12:35

Subject: git rebase issue
Message-ID: <CAHp75VfTQZ8vFQXZKgbsedG2BOad-pv9fCVkNkX+kFAxhnhhXQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAHp75VfTQZ8vFQXZKgbsedG2BOad-pv9fCVkNkX%2BkFAxhnhhXQ%40mail.gmail.com

```
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, 2023-03-13 12:58

Subject: Re: git rebase issue
Message-ID: <CAHp75VcZJPysc2-NXTC53XvOwbx-UfPO9SbsBJFb72JGHFyO1A@mail.gmail.com>
URL: https://gitlist.dev/e/CAHp75VcZJPysc2-NXTC53XvOwbx-UfPO9SbsBJFb72JGHFyO1A%40mail.gmail.com
In-Reply-To: <CAHp75VfTQZ8vFQXZKgbsedG2BOad-pv9fCVkNkX+kFAxhnhhXQ@mail.gmail.com>

```
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?

-- 
With Best Regards,
Andy Shevchenko

```

## Andy Shevchenko, 2023-03-20 12:10

Subject: Re: git rebase issue
Message-ID: <CAHp75Vc419vikJ184syJHN7rxyaspHzgtT9a_uFA=CT=cdqo-w@mail.gmail.com>
URL: https://gitlist.dev/e/CAHp75Vc419vikJ184syJHN7rxyaspHzgtT9a_uFA%3DCT%3Dcdqo-w%40mail.gmail.com
In-Reply-To: <CAHp75VcZJPysc2-NXTC53XvOwbx-UfPO9SbsBJFb72JGHFyO1A@mail.gmail.com>

```
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.


-- 
With Best Regards,
Andy Shevchenko

```

## Felipe Contreras, 2023-03-20 14:41

Subject: Re: git rebase issue
Message-ID: <CAMP44s2-hMXk0NSn0-SQWaxX3TOpYSbc17A-XGv0oi_D_Ws0dw@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s2-hMXk0NSn0-SQWaxX3TOpYSbc17A-XGv0oi_D_Ws0dw%40mail.gmail.com
In-Reply-To: <CAHp75Vc419vikJ184syJHN7rxyaspHzgtT9a_uFA=CT=cdqo-w@mail.gmail.com>

```
On Mon, Mar 20, 2023 at 6:32 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> 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

```

## Andy Shevchenko, 2023-03-20 17:20

Subject: Re: git rebase issue
Message-ID: <CAHp75VeMoXZdr++6BiOMhOnSqm5rPe+t0bNzpLJsCuGp8NU=wA@mail.gmail.com>
URL: https://gitlist.dev/e/CAHp75VeMoXZdr%2B%2B6BiOMhOnSqm5rPe%2Bt0bNzpLJsCuGp8NU%3DwA%40mail.gmail.com
In-Reply-To: <20230320170158.GA2614670@coredump.intra.peff.net>

```
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.

> 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

```

## Jeff King, 2023-03-20 17:01

Subject: Re: git rebase issue
Message-ID: <20230320170158.GA2614670@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20230320170158.GA2614670%40coredump.intra.peff.net
In-Reply-To: <CAHp75Vc419vikJ184syJHN7rxyaspHzgtT9a_uFA=CT=cdqo-w@mail.gmail.com>

```
[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:

> > > 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

```

## Felipe Contreras, 2023-03-23 20:37

Subject: Re: git rebase issue
Message-ID: <CAMP44s2hEudOpOcyXzZQNYtQSHXOd4NiPBboH=90RHEgF_Lamg@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s2hEudOpOcyXzZQNYtQSHXOd4NiPBboH%3D90RHEgF_Lamg%40mail.gmail.com
In-Reply-To: <CAHp75VeMoXZdr++6BiOMhOnSqm5rPe+t0bNzpLJsCuGp8NU=wA@mail.gmail.com>

```
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)?

-- 
Felipe Contreras

```

## Andy Shevchenko, 2023-03-24 07:52

Subject: Re: git rebase issue
Message-ID: <CAHp75VfSdth4B-oW8JCt4kBkehu6+B9ueQAJL1g99Ev3RiMKoQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAHp75VfSdth4B-oW8JCt4kBkehu6%2BB9ueQAJL1g99Ev3RiMKoQ%40mail.gmail.com
In-Reply-To: <CAMP44s2hEudOpOcyXzZQNYtQSHXOd4NiPBboH=90RHEgF_Lamg@mail.gmail.com>

```
On Thu, Mar 23, 2023 at 10:38 PM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
>
> 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, 2025-03-22 13:42

Subject: Re: git rebase issue
Message-ID: <CAHp75Vf8bB8o9feJHe4FpNo0TnfoRLG+C0roD4a1OaqN3NDj-A@mail.gmail.com>
URL: https://gitlist.dev/e/CAHp75Vf8bB8o9feJHe4FpNo0TnfoRLG%2BC0roD4a1OaqN3NDj-A%40mail.gmail.com
In-Reply-To: <20230320170158.GA2614670@coredump.intra.peff.net>

```
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.
> > > >
> > > > 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, 2025-03-23 01:37

Subject: Re: git rebase issue
Message-ID: <CAPig+cSswzF_Z9TsNEVi59ufdhwfZ+aN=NBmW+AmLwD2mFg8Pg@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcSswzF_Z9TsNEVi59ufdhwfZ%2BaN%3DNBmW%2BAmLwD2mFg8Pg%40mail.gmail.com
In-Reply-To: <CAHp75Vf8bB8o9feJHe4FpNo0TnfoRLG+C0roD4a1OaqN3NDj-A@mail.gmail.com>

```
On Sat, Mar 22, 2025 at 9:43 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> 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/

```
