jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.33k stars 1.83k forks source link

"Local branches" when working with git trees #3561

Open scallaway opened 5 months ago

scallaway commented 5 months ago

Discussion was the best label to put this under, but it's more a question for my understanding.

I've started using Worktrees as I finally have a decent use-case for them, but the one thing I'm noticing is that Lazygit seems to report all the branches that are on remote as "Local branches", even if they don't have any upstream associated with them.

In my case, this results in some 700 branches being listed in the "local branches", where I try and keep that as clean as possible (removing local branches that have been deleted on remote).

Is this purely because I cloned the repository with --bare? Or is it due to the interaction with worktrees. I didn't want to clone regularly and then work with worktrees as the additional folders it creates (for each worktree) would confuse things.

I've also tried running a git remote prune origin now that I've added an upstream, but that doesn't seem to sort things either.

Just some clarification on how this works would be great! (And anyway to clear out those excess branches)

gfvioli commented 2 months ago

Just today I ran into the same situation as you when testing bare repos on lazygit and personally I find it confusing. I think that I have a couple of suggestions to enhance the experience when working with worktrees on a bare repo:

To be honest, I'm not quite sure about the rationale to put worktrees on pane 2, my understanding is that while you can do worktrees on a NOT bare repo, as per ThePrimeagen video on it (link here), the structure is a mess. Thus I think the recommendation is to use bare repos when using worktrees such that you can use them as independent branches, which would lead to this recommendation.

I'll keep on experimenting with bare repos and I'll keep on providing feedback.