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

Add new command to checkout branch of remote repository #216

merged 2 commits into from Jun 7, 2017


Copy link

This is a feature that I've wanted in SublimeGit for quite a while, so I built it and have deployed it locally: Git: Checkout Remote Branch. I know there are some others who were hoping for a similar feature ( it's Issue #29 ), so I figured I'd submit it as a pull request. As implemented, it's perfect for my use-cases, but if you think any piece of it would be a valuable contribution to the core project, I'd be happy to adjust the implementation as needed to make it suitable for inclusion.

If you have other plans or if for any other reason this isn't of interest, don't worry about it. If you'd like a detailed description of this change, I've included it in this commit message


Finished building out the git_checkout_remote_branch command to add
the ability to checkout remote branches that are not present locally.
Added this as a new command, separate from git_checkout_branch to avoid
bloating the current feature and to allow users to choose which remote
to use. This has been an open request since 2013: Issue SublimeGit#29


 1. Open the Command Pallette, start typing some sequential subset
 of "Git: Checkout Remote Branch", and select the command

 2. Select a remote from the list (if any remotes have been set;
 warns and exits immediately if none can be found)

 3. Select a branch from the list of that remote's branches that do
 not yet exist locally (if any such branches exist; warns and exits
 after selecting the remote if none can be found)

This functionality would be fairly easy to move under a previously-
defined command if necessary, but I think keeping it separate makes the
experience cleaner. And the current command name matches
"git checkout branch", so it should be easy for users to find, even
without searching for it.

Overall, I tried to keep the code as centalized as possible so as
not to touch too many different files, even though some parts of it
should probably be extracted, for example, into `sgit/`.
Here are some additional details:

 - Ensured that only remote branches that do not exist locally are
available when using this command.

 - Removed comments and excess whitespace to more closely match the
rest of the code.

 - Finished adding existence assertions to remove the possibility of
this command failing silently.

 - Refactored the double list-comparison operation between the
list of remote branches and the list of local branches into a set union
operation to ensure essentially linear run-time (though the typical
lengths involved should be too small for that to matter much anyway.)

Resolves: SublimeGit#29
Copy link

Thanks for that @TJKresch
I'd love to have that feature as I mainly use branch created by other people from the remote.
@ the maintainer(s), is it possible to merge this PR?

Copy link

ykvch commented Jun 6, 2017

@miped Could You please review and merge this pull-request.
This should drastically improve the plugin (in certain use-cases).

Copy link

Unless I hear any objection (or hear otherwise) I'll merge this tonight (my time). Looks like a good change.

Copy link

👍 👍 👍

@sbuttgereit sbuttgereit merged commit 4f12f25 into SublimeGit:master Jun 7, 2017
Copy link

thank you @sbuttgereit and @TJKresch
Could we also have a release including this merge? 😁

Copy link

@Vincent-- you just want it all! (Jk)

I should be able to do something sometime between Wed and Sun. Biggest blocker is I have to figure out how to do it (first time for every thing) and not break it for every one. Out of town on business now so a little tough to nail it down more than that.

Copy link

ykvch commented Jun 13, 2017

According to:
adding git tag like "1.0.37" should be sufficient for this repository.
Also adding "messages/1.0.37.txt" file with short changelog and credits would be nice too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants