Problem when adding files to a worktree which is based on a bare repo
What steps will reproduce the problem?
- Run the following commands on a git shell to create a bare repo and related worktree:
mkdir tmp cd tmp git init --bare base.git # This is just to create an initial commit, work1 is not related to the bug at all git clone base.git/ work1 cd work1 git commit --allow-empty -m . git push cd .. # Create a worktree on work2 based on base.git cd base.git git worktree add ../work2 master
Those commands will create a worktree at folder work2 that shares the same gitdir with base.git. This feature allows you to check out multiple branches from the same git folder, and all git commands issued on work2 will use base.git as base.
Now, TortoiseGit will recognize work2 as a worktree right away and most commands will work on it.
- On Explorer create a new file, right-click and select TortoiseGit > Add.
What is the expected output? What do you see instead?
Tortoise were supposed to add the file to git without errors, instead, it shows
Error: libgit2 returned: cannot create blob from file. This operation is not allowed against bare repositories.
What version of TortoiseGit and Git are you using? On what operating system?
18.104.22.168 @ Windows 10
Please provide any additional information below.
I have to work on multiple branches simultaneously, so I created individual folders checking out from same remote. Problem is that this is eating my disk space. So I learned about
git worktree and I'm experimenting with it. Basically I created a bare repo, added my remote and fetched its branches and then created several worktrees for the branches I need to work on. So far, most of TortoiseGit works fine, except for adding new files.
If I open a git bash and manually add the files with
git add, it works fine and TortoiseGit recognize it as added files on Diff window.