jesseduffield / jesseduffield/lazygit
Lazygit crash when git worktree is delete and rename
- Dominant language
- Go
- Stars
- 82.4k
- Forks
- 3k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 19
Description
### Describe the bug
lazygit crash when git worktree is delete and rename
### To Reproduce
Steps to reproduce the behavior:
1. Open any git repo
```sh
cd p5
```
2. Create a new worktree
```sh
git worktree add ../p5-dev dev
# Output:
# Preparing worktree (checking out 'dev')
# HEAD is now at ba90c42 vibecode subcommand
```
```sh
git worktree list
# Output:
# /home/vancanh-ng/projects/p5 077bea1 [main]
# /home/vancanh-ng/projects/p5-dev ba90c42 [dev]
```
3. Delete worktree (p5-dev) and rename main repo (p5) to the old worktree (p5-dev)
```sh
cd ..
rm p5-dev -rf
mv p5 p5-dev
cd p5-dev
```
```sh
git worktree list
# output should be like below
# /home/vancanh-ng/projects/p5-dev 077bea1 [main]
# /home/vancanh-ng/projects/p5-dev ba90c42 [dev]
```
4. Run lazygit and observe: `lazygit` run for a brief second and then crash as shown in the screenshot
Although I know I shouldn't be manually deleting and rename a git worktree and should instead use `git worktree move` and `git worktree remove`.
This still took me a while to figuring out what went wrong. So, it would be nice if `lazygit` can gracefully handle this case.
For now, I just use `git worktree prune` and move on.
### Expected behavior
`lazygit` should not crash.
### Screenshots
### Version info:
commit=, build date=, build source='debian', version='0.57.0+ds1-1', os=linux, arch=amd64, git version=2.51.0
### Terminal info:
Windows Terminal 1.23.12811.0
### Additional context
Windows Subsystem for Linux - Debian (2.6.1.0)
Kernel: Linux 6.6.87.2-microsoft-standard-WSL2
git version 2.51.0
Contributor guide
Assessment
This issue has not been assessed yet.