Sublime Forum

Shortcut for git fetch

#1

I notice you can access git fetch in the command palette via ⌘P, but there’s no menu item for it. I rarely use git pull, and mostly fetch and look at the changes before deciding whether to merge or rebase.

Could we add fetch to a menu, so I can set a custom macOS shortcut for it?

I ususally delete branches once pull requests are merged too, so having a configuration option to specify --prune as the default would be great.

1 Like

Force push tag
#2

I think this will be possible with custom keymap bindings in https://www.sublimemerge.com/docs/key_bindings. It kind of works with:

[
{
“keys”: [“command+option+control+f”],
“command”: “git”,
“args”: {“argv”: [“fetch”, “–prune”]}
}
]

but I think it’d be better to go through an actual sublime merge command palette command as I think that gives better feedback in the UI about what’s happening.

0 Likes

#3

Similarly, you can add commands: https://www.sublimemerge.com/docs/command_palette

0 Likes

#4

This should be what you are looking for:

[
    {
        "keys": ["command+option+control+f"],
        "command": "fetch",
        "args": {"mode": "fetch --prune"}
    }
]
2 Likes

#5

This very nearly works, it doesn’t seem to automatically pass in the remote so it fails with the error: “fatal: No path specified. See ‘man git-pull’ for valid url syntax”

I also tried to do the shortcut via the command palette but it had the same problem with the remote:

{                                                                                                                                                                                                                                                      
       "keys": ["command+option+control+f"],
       "command": "show_command_palette",
       "args": { "command": "fetch", "args": { "mode": "fetch --prune"} }
}

I’m not sure how to pass in the remote, it seems there might be a $remote variable populated, but not sure of the format. At the moment, I’m just leaving the mode argument off, which leaves the command palette open.

0 Likes

#6

If it helps, Sublime Merge respects this config: git config --global fetch.prune true which prunes all fetches (and therefore pulls). Depends whether you always want to prune (personally, I have no reason not to).

1 Like

#7

I wasn’t able to resolve this via Sublime Merge’s internal “fetch” command, but this strategy for invoking an arbitrary git command did work:

{
    "keys": [ "super+option+control+f" ],
    "command": "git",
    "args": { "argv": ["fetch"] }
}
0 Likes