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

Sort all branches by last update #5155

Open
hubgit opened this issue Jul 13, 2018 · 14 comments
Open

Sort all branches by last update #5155

hubgit opened this issue Jul 13, 2018 · 14 comments
Labels
user-research Issues that might benefit from user interviews, validations, and/or usability testing

Comments

@hubgit
Copy link
Contributor

hubgit commented Jul 13, 2018

Is your feature request related to a problem? Please describe.

Showing recent branches is a great feature, but I often have trouble finding a fairly recent branch because it's disappeared from the short "Recent Branches" list.

Describe the solution you'd like

Divide the list of branches into "Local Branches" (sorted by date) and "Remote Branches" (sorted by date), instead of "Recent Branches" (sorted by date) and "Other Branches" (sorted alphabetically).

It's not very useful to have branches sorted alphabetically, as you can already type to filter them.

Describe alternatives you've considered

Switching to the command line and using a custom git branches alias:

for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'

Teachability, Documentation, Adoption, Migration Strategy

This would replace the current dropdown list of branches.

@shiftkey
Copy link
Member

Showing recent branches is a great feature, but I often have trouble finding a fairly recent branch because it's disappeared from the short "Recent Branches" list.

I'm actually more interested in this part of the issue than changing the sorting, because I've spent a bit of time in there thinking about how it works.

I think the core of your problem is that we don't consider whether a branch exists in the list when we're reading the reflog. I can see this in my local Desktop clone after pruning some merge branches:

Are you pruning your merged branches? I think the fact that our getRecentBranches function here doesn't confirm a branch exists locally mean we can end up often showing fewer branches than the 5 allowed.

export async function getRecentBranches(
repository: Repository,
limit: number
): Promise<ReadonlyArray<string>> {

@shiftkey shiftkey added the more-info-needed The submitter needs to provide more information about the issue label Jul 17, 2018
@shiftkey shiftkey self-assigned this Jul 23, 2018
@hubgit
Copy link
Contributor Author

hubgit commented Jul 25, 2018

Are you pruning your merged branches? I think the fact that our getRecentBranches function here doesn't confirm a branch exists locally mean we can end up often showing fewer branches than the 5 allowed.

The remote branches are being deleted when they're merged, but the local branches aren't being pruned. Does the list take account of which branches are in the origin repository and which have been merged, or is it literally just the most recently-edited local branches?

If I run the git branches alias that's in the issue description, I can see 5 local branches edited in the last 24hr, but GitHub Desktop only shows 4 of them (+ master).

There could easily be more than 5 branches edited in the last 24hr, as well.

I'm interested to know when it's useful to have branches listed in alphabetical order, rather than by date.

@shiftkey
Copy link
Member

@hubgit thanks for the extra details

Does the list take account of which branches are in the origin repository and which have been merged, or is it literally just the most recently-edited local branches?

No, the code has zero context on the actual branch details and just walks the reflog to find the N most recent branches that were checked out locally. This is what we consider "recent" - branches that you've checked out locally, and we don't look at the most recent commit to each branch.

I can see 5 local branches edited in the last 24hr, but GitHub Desktop only shows 4 of them (+ master).

This makes sense - we mark master as the default branch, so it gets listed before these recent branches and we show one fewer.

I'm interested to know when it's useful to have branches listed in alphabetical order, rather than by date.

This is mostly just mirroring the defaults of git branch

@shiftkey shiftkey added user-research Issues that might benefit from user interviews, validations, and/or usability testing and removed more-info-needed The submitter needs to provide more information about the issue labels Jul 25, 2018
@shiftkey
Copy link
Member

@billygriffin would love your thoughts on two related questions here:

  • the recent branches list - using the reflog or looking at the most recent commit timestamp? We've gone with the former option because that felt more focused on you, but if you're in a more collaborative situation using the commit timestamp means you might able to keep up with activity from collaborators

  • sorting the branch list - alphabetical versus date? Do we follow Git here and list alphabetically in a predictable way, or would seeing up-to-date branches be helpful for finding things in some situations?

@billygriffin
Copy link
Contributor

@shiftkey @hubgit Thanks for clarifying this, and sorry for the delay in responding. The potential for misaligned expectations vs what's actually presented makes total sense. I added this to our research list (and the label is helpful in reinforcing that). I don't see it as insanely high priority, but definitely worth examination in the next few months as we dig into usability more generally.

I think there are two things here:

  1. We should choose whatever patterns are most useful to people, which I think we've attempted to do but may need to re-evaluate with observing people using the app.

  2. Whatever we do arrive at, we should make sure the words we use to communicate them match people's expectations. So in this case, we say "Recent branches", but if "recent" means different things to different people, we need to choose clearer language.

Also want to make sure @ampinsk and @donokuda have visibility on this.

@shiftkey shiftkey removed their assignment Aug 1, 2018
@oguzyildizz
Copy link

It would be also great if I could increase the number of recent branches displayed in there. Once a branch I'm trying to get is 6th most recent one, finding it takes a bit time

@outofambit
Copy link
Contributor

Thanks for the bump here @oguzyildiz1991 ! There's another conversation happening in #7755 that I've linked this issue to.

@jcushman
Copy link

I'll just add another user story for this feature. I often use "recent branches" to switch between the last few branches when I'm working on a couple of things at once. But if I start working on something and then move away for a little longer, I'll have to do something like git for-each-ref --sort=-committerdate refs/heads/ | less to find it again because the list only has five items. "Other branches" has hundreds of branches and doesn't serve any use for me when ordered alphabetically.

@oguzyildizz
Copy link

oguzyildizz commented Nov 23, 2020

Exactly. If you're working on 5 branches it's alright, but once you're looking for the 6th most recent branch, suddenly you gotta go on an adventure

@steveward
Copy link
Member

In #13105 it was brought up that remote branches do not appear in the Recent branches list. Showing them would align with what was mentioned in #5155 (comment):

but if you're in a more collaborative situation using the commit timestamp means you might able to keep up with activity from collaborators

@teadrinker
Copy link

The way I perceive recent, is "locally recent" - which branches I have actually recently used/switched to, on this machine).
I think this functionality is fine, and I don't need more than 3 of these for my own usage.

However, it is very annoying that I cannot see new branches that have been added remotely (we have a lot of branches).
For this issue, I would suggest a selection of sorting (Name or Date), ideally this option is global, and saved automatically with app settings.

dropdown

@Janpot
Copy link

Janpot commented Jun 1, 2022

Another option could be to add a "show more..." button at the bottom of the 5 most recent branches, to increase the list with 5 more.

@steveward
Copy link
Member

Requested in #14828

@steveward
Copy link
Member

From #16897:

When attempting to switch to a new branch, the Recent Branches list typically does not show the actual most recent branch(es). If I don't know the branch name, I have to open GitHub on the web, where the Active Branches list does show the most recent branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user-research Issues that might benefit from user interviews, validations, and/or usability testing
Projects
None yet
Development

No branches or pull requests

9 participants