-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Describe the bug
I was deleting some old local branches when suddenly the operation stopped working for any subsequent branches until I restarted lazygit.
Investigating further, it turns out this was due to one of the deleted branches being master/main (I accidentally had created both).
After deleting one of them, self.c.Model().MainBranches is not updated and still thinks both exist. All subsequent deletes go through ConfirmLocalDelete -> allBranchesMerged -> IsBranchMerged where it will fail the rev-list and stop any further processing. Restarting lazygit fixes this since MainBranches will be repopulated with the correct values.
To Reproduce
Steps to reproduce the behavior:
git init -b master
git commit --allow-empty -m "Test"
git branch main
git branch dev
lazygit- Delete branch main, succeeds
- Delete branch dev, fails
Opposite delete order succeeds.
Expected behavior
Deletes should not fail.
I think one potential approach to fix this could be on IsBranchMerged error, call some new function that retriggers determineMainBranches, and then retry the branch merge check again (if it fails a second time, bail). These errors should be very infrequent but if they do happen, a refresh+retry should most likely fix it. Bonus is it will handle branches being deleted outside of lazygit.
Screenshots
Version info:
commit=80223c7fbbd0b86631a988834cbe88e267bb0bd9, build date=2025-11-01T09:43:19Z, build source=binaryRelease, version=0.56.0, os=windows, arch=amd64, git version=2.46.0.windows.1
Terminal info:
Windows Terminal
Additional context
Add any other context about the problem here.
Note
Please try updating to the latest version or manually building the latest master to see if the issue still occurs.