atom / github

:octocat: Git and GitHub integration for Atom
https://github.atom.io
MIT License
1.11k stars 393 forks source link

Improve branch management #556

Open smashwilson opened 7 years ago

smashwilson commented 7 years ago

Our current BranchMenuView tooltip control has a few major limitations:

I'd like to start a discussion about what to replace it with and what capabilities we want it to support. There's a balance to strike between overwhelming users with a panel that has a million checkboxes on it, but providing enough functionality to keep people from context-switching to the commandline as much as possible.

Here are a few ideas about features we might like to support:

@simurai already has some mockups to consider in other issues: https://github.com/atom/github/issues/302#issuecomment-279124372, #311.

simurai commented 7 years ago

Looking at #302 + #311 with a long list doesn't seem such a good idea anymore:

Tooltip Top bar
_branch 1

Often that tooltip/dropdown will going from top to bottom. Or we have some max-height, but that might feel frustrating on a larger monitor. Also, you would've to be very carful to not loose focus and accidentally close the tooltip/dropdown. Less a problem for simple branch switching, but if we want to add more management features, it would be good to not have to worry about loosing focus.

TL;DR: Should we move branch management back to a side panel? Not part of the current commit panel like it used to be, but into its own panel. This proposal seems very timely too.

simurai commented 7 years ago

Here branches in a panel:

screen shot 2017-03-02 at 12 57 19 pm

Context menu

Most actions are available in a context menu, some that come to mind (and not in a particular order):

As always, this is just "where things could go ™" and can be done in multiple steps.

Also /cc @donokuda that has a secret thing for branch UIs.

simurai commented 7 years ago

Some more questions:

What happens if you click on a branch with the mouse? Does it do a checkout or just select the branch? Probably the later. At some point we might want to show the commit history when selecting a branch. To do a checkout without using the context menu, you could double-click, like when staging/unstaging.

Also, how do you open the context menu with the keyboard if you want to do anything other than a checkout? On macOS you could enable it but it's not on by default.

Then I guess we also need a way to manage the remotes? Like adding, renaming, deleting.

winstliu commented 7 years ago

This looks awesome! My only concern is that the shield icon could get mistaken for protected branches.

thomasjo commented 7 years ago

My only concern is that the shield icon could get mistaken for protected branches.

Yeah, I agree. What about using image (home) or perhaps one of these?

image image image image

smashwilson commented 7 years ago

:heart: I love the direction this is going in!

Some thoughts on specific bits:

Circle (on the left): this is an indicator for branches that are tracking a remote branch

This one isn't obvious to me. The behind/ahead indicator already marks a branch as tracking; do we need a different indication? I think it also collides with the dot-for-current element; my brain keeps wanting the two elements to be related.

[Delete merged branches]

:+1: I have a git-delete-merged script to do this on the command-line now.

Would this make more sense as a context menu option on a specific branch, though? Then it becomes "delete branches merged into branch X" which feels less ambiguous to me.

We'd also likely want either some kind of confirmation about which branches you're about to delete or an easy undo.

[Rebase]

This would make more sense to me as "rebase your current branch onto the selected branch."

[Create branch] [..] Maybe for remote branches even track and do a checkout since you most likely wanna do that too.

:+1: :sparkles: Definitely.

[Pull/Push]

Does this make sense for branches that aren't currently checked out? I think Push can work, but Pull requires a working copy to handle any possible merges. We could automagically stash/checkout/pull/checkout old/stash pop but offhand I'd think there are too many things that could go wrong in those intermediate stages and leave your repository in odd states without enough indication of how you got there.

Does it do a checkout or just select the branch? Probably the later. At some point we might want to show the commit history when selecting a branch. To do a checkout without using the context menu, you could double-click, like when staging/unstaging.

:+1: for just selecting the branch and checking out on double-click.

Then I guess we also need a way to manage the remotes? Like adding, renaming, deleting.

See #555! Ideally we could integrate the two: from the branch view, navigate to the remote management UI with a specific remote focused, and from the remote view, navigate to the branch view with a specific remote focused.

Overall

simurai commented 7 years ago

@50Wliu My only concern is that the shield icon could get mistaken for protected branches.

Oh.. you're right. I just looked at https://github.com/atom/github/branches and didn't realize that the default branch is also protected. So yeah, we could have both:

simurai commented 7 years ago

@simurai Circle (on the left): this is an indicator for branches that are tracking a remote branch @smashwilson This one isn't obvious to me. The behind/ahead indicator already marks a branch as tracking; do we need a different indication? I think it also collides with the dot-for-current element; my brain keeps wanting the two elements to be related.

Ya, I'm also not too convinced about that. My intention was to find a way to show which of the remotes a local branch is tracking. This is to prevent the "why do my commits not show up... ohh.. I pushed to my personal fork :triumph:". It might be more clear when forks use a different color:

screen shot 2017-03-03 at 11 34 47 am

Hmm.. maybe too much 🎄

Writing out the full path would also be possible: another-remote/some-experiment. But then there are space/truncation concerns.

Here just checkmarks for the current branch. And a tooltip when hovering the ahead|behind counter:

screen shot 2017-03-03 at 11 54 04 am

simurai commented 7 years ago

[Delete merged branches] 👍 I have a git-delete-merged script to do this on the command-line now. Would this make more sense as a context menu option on a specific branch, though? Then it becomes "delete branches merged into branch X" which feels less ambiguous to me.

Isn't that a lot of work having to got through all branches to figure out which branch has unmerged commits? Yeah, maybe we could give a preview first. Like the context menu would say "Show branches where all commits commits got merged". Then you can see them first before you "select all" and delete them for good.

[Rebase] This would make more sense to me as "rebase your current branch onto the selected branch."

Would the selected branch be checked out afterwards? As far as I understand this all, you only can "receive" so that you can handle potential merge conflicts. Or would it checkout selected branch -> rebase -> checkout previous branch (without you noticing). So then it would feel like "giving" your commits to the selected branch.

How would you feel about promoting this to its own full PaneItem rather than just a tab in the panel? .com gives branches their own full page which is pretty nice. Maybe we could use the extra space to show more branch information (last commit message snippet, avatar, timestamp?) and some explicit controls for some of the context menu actions. Not 💯 pushing for this, just a thought.

🤔 The additional space sounds nice, but maybe a bit overkill when just switching branches or creating a new one?

Another idea to see "last commit message snippet, avatar, timestamp?".. well, kinda depends on how https://github.com/atom/atom/issues/13878 pans out:

screen shot 2017-03-03 at 3 14 22 pm

"Link" the branch panel with a history panel. Then if you split panes and have them side by side you can select a branch and see its commits. And selecting a commit would show the diff for that commit. Then at any time you can check out what's happening on other branches without having to check them out first. Or you can cherry pick a commit into your current branch. Anyways, let's not drift off too far and stay on topic. 😇

Could we add some kind of decoration or icon to highlight the tracking branch of the current branch? Maybe it's too obvious in the common case where they share a name.

Would the two checkmarks in https://github.com/atom/github/issues/556#issuecomment-283852568 help? Could also be a link 🔗 icon. Then even if the names are differnt, you still see which remote branch is being tracked.

Maybe add a "tags" group like the remote groups? I'm not sure where a "create tag" action belongs.

Yeah, could be another group. To create a tag, you need to tell the exact commit, right? Maybe wait until there is a history view so you can tag from there.

simurai commented 7 years ago

How would you feel about promoting this to its own full PaneItem

Ok, at least somebody would appreciate the extra space 👇 :

screen shot 2017-03-04 at 2 19 51 pm

btw. would it be possible to keep the current tooltip in addition to a new panel/pane with all the management options? Maybe not forever but just to see how its usage changes when we would have both. One reason I like the tooltip is because it auto-closes (when focusing away) and it feels like less work. Be able to close the panel with esc might be fine to.. like find+replace, a quick in-n-out.

cbovis commented 7 years ago

@simurai the dots and ticks feel confusing to me personally. The dots feel like radio buttons and the ticks feel like a selected state. The Git Plus package actually uses ticks in their Cherry Pick interface to signify which commits you've picked.

I like what the Tower git client does with regards to indicating the HEAD and upstream/downstream changes...

head

Absolutely love the idea of the contextual panel you mocked up for history. I could see this being used elsewhere for stashes with the main panel listing the stashes and the contextual panel displaying the changes for a particular stash.

surdu commented 7 years ago

One small improvement on the current implementation of New Branch, that might get carried into the next version as well is to have the last branch name you've previously created filled in the branch name and pre-selected.

My use-case is when you work with a git-flow-like style of branching, and you have to create branches like feature/.... Having the text there, it's easy just to use the arrows to get rid of the text pre-selection and modify the branch name instead of typing it all from the beginning.

If you don't need the previous branch name, having the text pre-selected in the input allows you to just start typing the new name and the new name should override the old one.

If this is something that you guys find desireable, I could try to work on it myself.

simurai commented 7 years ago

@surdu have the last branch name you've previously created filled in the branch name and pre-selected.

👍 That's a great idea. Maybe one small concern: It then might feel like you're branching off from your previous branch and not the one that you are currently on (and showing in the status-bar).

So instead we could do something similar to find-and-replace. There you can hit the ⬆️ key to cycle through your previous searches.

We could still prefill the branch name but it might be safer to only prefill with your current branch name. For example if your current branch is feature/branch-management and you click on "New Branch", you probably want to create an alternative like feature/branch-management-alternative. Not having to type the beginning would be super handy.

And when you're on master, then keep it empty since the branch name could be anything.

surdu commented 7 years ago

@simurai We could still prefill the branch name but it might be safer to only prefill with your current branch name.

When I create feature branches I usually create them from develop/master not from another feature branch. I might be wrong, but so should be all the other people that follow a git-flow strategy. So filling the input with the branch name might be as useful as leaving it empty for these people.

The up arrow key is a great idea, but has the downside that might not be intuitive for the users that they can do that. That being said, I and many others have discovered that you have a history in find-and-replace input and it's not hinted in any way.

hamza commented 7 years ago

Not sure if this is out of scope for this, or if it already exists (can't find it if it does), but it would be great to add keystroke bindable commands for branch related stuff, something like

github:switch-branch github:new-branch

etc. Similar to what you find in the GitHub desktop app.

calebmeyer commented 7 years ago

I came to atom from spacemacs, and a nice keyboard based workflow for branching is something I've been sorely missing.

In spacemacs, you get to the git status panel (magit-status) with space g s, and from there you have keyboard commands for pushing, pulling, fetching, checking out, branching, etc. (this is due to emacs not always being in a mouse environment)

2017-09-15 12_30_19-

One of the things that confused me at first about their branching is you're required to always select a starting branch (it doesn't assume your current branch like git branch does). That's something we can definitely improve on. For a mouse based workflow, you can do the right click > checkout. For a keyboard based workflow, maybe we have a dropdown pre-populated with the current branch that can be shift-tabbed to? I'm not good at mockups, but I'll attempt an ascii art one:

Git: Checkout New Branch

  Base Branch
+--------------------------+
|  current-branch-name   v |
+--------------------------+

  New Branch
+--------------------------+
|  |                       |
+--------------------------+

Here the new branch input is a standard text input and has keyboard focus, and the base branch is a dropdown that supports searching with the keyboard.

ambischof commented 6 years ago

For the issue of too many branches, I think a big help would be to sort the branches by last committed to. In my local setup I typically do git branch --sort=-committerdate so the recent branches are on top. I'm also a fan of --no-merged flag