Sublime Forum

How to Checkout Branch and Track Remote

#1

Hi,

This is probably a silly question, but how do I check out a remote branch locally for the first time? I pulled the repo and can see the branch in the commit history, but I can’t change to it using ‘Checkout Branch’ as it’s not in the list.

I also tried ‘Checkout Remote Branch’ but it doesn’t create it locally.

Thanks!

0 Likes

#2

There’s a context menu entry for “Create local branch from origin/foo” that will do this

1 Like

#3

We can’t set a remote branch though, can we? Or, like, when we create a new branch create it while pushing? Had to use command line for this.

0 Likes

#4

That option did the trick, thanks jps!

0 Likes

#5

This was very confusing to me and I had to drop to the command line to fix it.

I create a new local branch, committed changes and then pushed it to the remote. But it didn’t start tracking it. I could see no way in Sublime Merge to track it. I had to drop to the command line and run
git branch -u origin/branch_name

Am I missing the sublime merge command that can add tracking to an already existing local and remote branch?

0 Likes

#6

The -u option is short for --set-upstream-to=<upstream>, therefore:

  • right click the branch/commit and pick Set Upstream...
  • or with the command palette: Set Branch Upstream

It should have, are you sure you didn’t hide the remote branches & therefore didn’t see the newly created & pushed remote branch?

2 Likes

#7

I also have this problem. If I create a new local branch, in order to emulate git push -u origin my-branch, I need to do two steps:

  1. Press the normal push button (up arrow)
  2. Right-click on the commit and pick “Set Upstream…”

Is there a way to pass the “–set-upstream-to” flag on the original push? I think this is almost always the expected behavior when pushing to a new remote branch.

0 Likes

#8

@sffc, Sublime Merge does exactly that for all non-pushed branches when running the push command (you’ll see [Push branch-name origin/branch-name] in the command palette).

0 Likes