Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order remote branches by date of last commit #1412

Closed
jkogler-cloudflight opened this issue Aug 2, 2021 · 2 comments · Fixed by #3171
Closed

Order remote branches by date of last commit #1412

jkogler-cloudflight opened this issue Aug 2, 2021 · 2 comments · Fixed by #3171
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jkogler-cloudflight
Copy link

Is your feature request related to a problem? Please describe.
In our company we have way too many branches remotely. Basically everybody creates new ones for every PR, and most of the time the branches don't get deleted afterwards.
That makes it very hard to check out a remote branch with lazygit, as I have to search for it. Need to know the exact PR number, ...

Describe the solution you'd like
I would like that the remote branches are ordered by the date of their last commit, and not alphabetically (similar to the local branches (although they are sorted by last checkout, not by last commit).
Or at least I would like to have the option to enable such a sorting.

Describe alternatives you've considered
I know the best solution would be that my team enforces a delete-branch-after-merge policy, but I would still appreciate this feature. Not sure if everybody can enforce it, and that still leaves all he stall branches that don't get merged.

Additional context

@jkogler-cloudflight jkogler-cloudflight added the enhancement New feature or request label Aug 2, 2021
@jesseduffield
Copy link
Owner

Sounds a lot like my company haha. This sounds like a sensible change to me. I wonder if it's expensive to grab the last commit date for each remote branch, but I suspect it's not.

@apaatsio
Copy link

apaatsio commented Feb 8, 2022

A simple solution is to replace the git command in:

remoteBranchesStr, err := self.cmd.New("git branch -r").DontLog().RunWithOutput()

with

"git for-each-ref --sort=-authordate refs/remotes --format=\"%(refname:lstrip=2)\""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
3 participants