JetpackDuba / Gitnuro

A FOSS Git multiplatform client for newbies and pros
https://gitnuro.com/
GNU General Public License v3.0
946 stars 46 forks source link

checking out branches that were updated upstream is not intuitive #119

Closed adam-ce closed 1 year ago

adam-ce commented 1 year ago

Describe the bug you can't check out a branch via the remote handle visible in the tree, if it was checked out before, but is not up-to-date. An error pops up, saying "Ref branch_name already exists".

To Reproduce

  1. create a repo with a main branch 'main' on machine A
  2. create a branch 'B' on machine A
  3. push to a remote (e.g. github) from machine A
  4. clone the remote on a different machine B
  5. checkout 'B' on machine B
  6. checkout 'main' on the machine B
  7. commit something to 'B' on machine A
  8. push to the remote on machine A
  9. pull / fetch the branch main on machine B (the commit to branch 'B' will become visible in the tree view).
  10. try checking out 'origin/B' on machine B (it'll fail)
  11. checking out 'B' (the local branch) on machine B works (but the local branch might be so many commits behind, that it is outside of the view)

Expected behavior

a text 'checkout origin/B' might be confusing as a menu entry (since the branch is already locally available, and might contain other commits). so therefore i would expect an entry saying 'checkout local branch and pull', or only 'checkout local branch'.

Desktop (please complete the following information):

JetpackDuba commented 1 year ago

Hello,

Yes, it's not a bug but rather a lack of alternative of options, it's part of this issue https://github.com/JetpackDuba/Gitnuro/issues/30

It's not something specific to this but to a big part of the daily errors the users may face. It requires some exception messages parsing (which is not ideal but the seems to be the only option) and provide a good error message accordingly.

I've got some examples designed in Figma for other common errors, here is an example: image

JetpackDuba commented 1 year ago

I've referenced your message there to have the discussion in a single place.

JetpackDuba commented 1 year ago

Something else to add is that in some specific cases, the local branch may not be referencing the remote branch with the same name, as you can have multiple remotes. There is also the case where a local branch named X references a remote branch named Y, making things even harder.

Probably the first case should is the most relevant but both cases should be investigated.