Sublime Forum

Support "git fetch origin branch:branch"

#1

If I have a branch checked out, I can pull another branch without checking it out by running
git fetch origin branch:branch

for example, if I’m in a feature branch, but want to pull the latest silver, I can run
git fetch origin silver:silver

This is useful when I want to rebase my branch onto silver without having to checkout silver first.

Sublime Merge won’t let me run that command, I have to switch to a git bash to do that. It would be great if this was supported from within the command palette.

Thanks!

Edit: for reference - https://stackoverflow.com/questions/3216360/merge-update-and-pull-git-branches-without-using-checkouts/17722977#17722977

1 Like

Quick way to checkout remote branch after fetch?
#2

So the issue is that you only want to fetch a single branch from the remote, not all branches?

0 Likes

#3

I’d like to be able to pull a branch that I don’t currently have checked out. I’m able to do that via git bash with a single command (see example above), but I’m not able to do that from the Sublime Merge command palette. When I try “fetch origin silver:silver” from the command palette, it doesn’t let me submit the command.

The command palette is great because it tries to help with things it knows I want, and prevent me from doing things it thinks is wrong. In this case though, it’s preventing me from doing something that is valid, I suspect because it thinks it’s invalid.

0 Likes

#4

See also https://github.com/sublimehq/sublime_merge/issues/242

0 Likes

#5

Yes, that would be perfect.

0 Likes

#6

A work around would be to use the fetch command and then rebase on origin/branch-name.

0 Likes

#7

Thanks @srbs

0 Likes

#8

You suggestion of a custom menu item from this thread is perfect.

[
	{
		"caption": "Pull $branch",
		"command": "git",
		"args": {"argv": ["fetch", "origin", "$branch:$branch"]}
	}  
]

That lets me right click on a branch and have it “pull” the branch without me having to switch branches first.

Thanks!

3 Likes

Feature request: single branch operations
#9

Glad you saw that thread, guess I forgot to write a comment here as well.

1 Like

#10

The system notified me, I guess it’s smart enough to know that if you link to this thread, I might be interested.

0 Likes