Sublime Forum

Sublime Merge and branches

#1

I’ve cloned a repo and Sublime shows me on the master branch. When I click the top-center ‘master’ dropdown, I’m offered ‘Checkout Branch’. This lists no branches and typing in the name of a remote branch and hitting enter does nothing (it doesn’t respond that I made an error and seems to give no clue as to why it didn’t do what I wanted).

After a little research I realize that it is expecting me to type the name of a local branch, not a remote branch. I work exclusively with remote branches, not local, so this didn’t jump to mind as a potential reason.

So that I understand Sublime Merge and git workflow better, can you explain why it only shows local branches? Also, I wonder if you would consider modifying the text to clarify that it’s expecting you to type (or perhaps select) a local branch, or otherwise show some kind of response when you type a remote branch and hit enter, rather than sit silently.

Additionally, once I have actually checked out the remote branch using the left-sidebar REMOTES(N) > name > branch, the top-center label shows a commit hash rather than user/feature-branch-xyz. Why is that? This seems to be a detached HEAD (as reported by git status).

0 Likes

#2

Merge is a wrapper on git, and in most situations does the same things at git would do. This is an instance of that being the case; A checkout of a commit that is not the name of a local branch branch will get you into a detached state.

For example:

D:\Projects\OverrideAudit (master -> origin)
λ git checkout origin/context-menu-changes
Note: checking out 'origin/context-menu-changes'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 7eb01d1... Alter how context menus work

Just to the left of the text that shows you the current HEAD state (branch name or hash) is an icon of a terminal; if you click that, you can see exactly what git commands Merge is executing and what git responded with as it did it.

I’m not one of the devs, but I suspect that this is the reason for this. The command that’s triggered when you click the dropdown is the Checkout Branch command, which does the same as git checkout does.

Presumably the intention is that if you want to check something out you want to work with it, and in that case you probably only want to check out a known branch; otherwise you would Create Branch or Checkout Remote Branch instead.

1 Like

#3

Thank you for the response Terence.

0 Likes