I have a git repository checked out and have created a worktree for one of the branches. I hadn't updated the worktree directory in a while, so when I ran git pull
it was taking a while. In another terminal, I ran git pull
on the "base" directory.
While the worktree was still working, the base directory was just waiting. The worktree showed the usual long scroll of adds/changes/deletes, and about halfway through that, the base directory started showing the long list of updated references.
The worktree finished completely. The base showed in the ref list several errors like this:
error: cannot lock ref 'refs/remotes/origin/<redacted>/<redacted>': is at <redacted SHA> but expected <redacted SHA>
Is this use case not supported by worktrees? Is it possible to harm the contents of the repo with simultaneous operations?
You can't harm the repo this way.
Both worktrees work on the same
.git/
directory on disk, your action would be the same as running twogit fetch
from two different terminals.I don't know the precise sequence of steps executed by git in this case, but the end result will be a coherent repo.