Open XavierChanth opened 7 months ago
Alright, so this has lead me down a git rabbit hole which may be worth sharing...
Since I don't actually want to copy all of the remote refs to my local anyways (this is a result of using bare repos, not anything to do with lazygit), the better way for me to checkout the repo is:
git clone <url> -n -c core.bare=true
This way, it should behave like a bare repo, but 2 things are different:
.git/
directoryI have yet to determine if there are any other side effects in doing this, but I guess I will find out the hard way if there are. Hope this helps anyone else with similar issues.
Update:
From the context of the root of the repo, both $GIT_DIR and $GIT_COMMON_DIR will be .git instead of "." which could cause some tooling to put things inside of .git/ instead of the root.
I suppose there are ways of fixing the refs, but this fits my usecase of lazygit + worktrees well enough.
Is your feature request related to a problem? Please describe.
Working with bare repositories + worktrees makes the local branches tab quite useless. With a bare repo,
git branch
lists all of the remote branches as local.Describe the solution you'd like I would like to use the following sorts:
--sort=-worktreepath --sort=-HEAD
, this will list the current worktree first, then all other worktrees, then all other branches which are not checked out in a worktree.Describe alternatives you've considered Tried looking for config options, this will not work in gitconfig since
branch.sort
is only used by git if--sort
is not specified (but lazygit always passes--sort
)Additional context
The other thing that contributes to this problem is that with recency (the default sort) as the default sort, recent branches are not recent in the context of multiple worktrees. Since if I checkout branchA and then branchB in separate worktrees, branchA will not be considered recent from branchB since branchA wasn't checked out recently from branchB's worktree. So it pretty much sorts HEAD then everything else alphabetically, assuming a one-branch-one-worktree workflow.
Example of the sort:
git branch --sort=-worktreepath --sort=-HEAD
:Where trunk is the current worktree, and c_daemon is the only other worktree.
Happy to work on a PR for this over the weekend.