git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug: git worktree remove and overwritten directory
@ 2020-05-20 10:36 Jonathan Müller
  2020-05-20 13:38 ` Shourya Shukla
  2020-05-20 14:22 ` Eric Sunshine
  0 siblings, 2 replies; 6+ messages in thread
From: Jonathan Müller @ 2020-05-20 10:36 UTC (permalink / raw)
  To: git

Apologies, if this has already been reported.

It seems to be impossible to remove a git worktree whose location has 
been replaced by the main working tree (don't ask how I found out). 
Steps to reproduce:

```
git init test
cd test
git commit --allow-empty -m"Initial commit"
git branch some-branch
git worktree add ../test2 some-branch
cd ../
rm -rf test2  # Remove the worktree folder
mv test test2 # Main git repository now located where the worktree used 
to be
```

Afterwards, `git worktree list` reports:

/home/foonathan/test2  e7bb748 [master]
/home/foonathan/test2  e7bb748 [some-branch]

And both `git worktree remove .` and `git worktree remove ../test2` 
report an error `fatal: '../test2' is a main working tree`. I had to 
manually remove the corresponding folder from `.git/worktree` to get rid 
of it. The issue is especially annoying, because you can't check out 
`some-branch` anymore (as it's already checked out in the worktree).

I've tested it with git version 2.26.2 and also the version currently on 
the next branch.

Thank you,
Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-08 14:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 10:36 Bug: git worktree remove and overwritten directory Jonathan Müller
2020-05-20 13:38 ` Shourya Shukla
2020-05-20 14:22 ` Eric Sunshine
2020-05-20 14:28   ` Jonathan Müller
2020-06-08  6:42     ` Eric Sunshine
2020-06-08 14:07       ` Jonathan Müller

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).