Sublime Forum

Keybinding command for force push with lease?

#1

I’d like to add a keybinding for push force with lease.

Unfortunately the documentation for the available commands is basically “just read the default keybindings”, which of course doesn’t help at all for commands that don’t have a key binding yet.

So what are the args to enable force push with lease?
[
{
“keys”: [“super+alt+shift+up”],
“command”: “show_command_palette”,
“args”: {“command”: “push”, “args”: ???}
},
]

0 Likes

#2

G’day @UloPe,

Thanks for reaching out!

To create this command, you can use the built-in push command.

The command takes three arguments:

  • branch — the name of the branch to push
  • remote — the name of the remote to push to
  • mode — the type of push to perform

Any of these arguments can be excluded, and Sublime Merge will prompt you if it can’t automatically determine them.

In order to force push, you’ll want to set the mode argument. The mode argument has the following options:

  • push
  • push --set-upstream
  • push --force
  • push --force-with-lease
  • push --no-verify

If you’re wanting to always push the currently checked-out branch, you’ll need to set the branch argument too. Sublime Merge has a special $head value, that evaluates to the currently checked out branch.

Putting this together, you can do something like this:

[
    {
        "caption": "Force Push With Lease",
        "command": "show_command_palette",
        "args":
        {
            "command": "push",
            "args": { "branch": "$head", "mode": "push --force-with-lease" },
        }
    },
]

As an aside, I’m looking into ways to improve our documentation of commands to make defining custom commands easier.

Cheers,
- Dylan from Sublime HQ

1 Like