I'm working on some server-side software to do a merge. By using git worktree
it's possible to check out a given branch for a bare repo and merge another branch into it. It's very fast, even with large repositories.
The only exception seems to be merging to master
. When I do git worktree add /tmp/path/to/worktree master
I get an error:
fatal: 'master' is already checked out at '/path/to/bare/repo'
But this is clearly not true, git worktree list
gives:
/path/to/bare/repo (bare)
...and of course, there is no work tree at that path, just the bare repo files you'd expect.
UPDATE: I got in touch with the git maintainers, and they have agree that this might be a bug. I have a preliminary patch from them to test. In addition, I have also been able to reproduce the desired behavior without the patch.
At this point I'm not entirely sure what the boundary condition or root cause is, and there might be a fix forthcoming from git.
-b
option to create a branch for this to work. – Ambiversion