Sublime Forum

How to map Git Push to keyboard shortcut

#1

For some reason it’s incredibly difficult to simply map a keyboard shortcut to git push. I’ve turned on logging and still can’t figure it out after hours of research. I’ve search google to death… nothing on stackoverflow or blogs or reddit

Here is log command output from console.

command: show_overlay {"overlay": "command_palette"}
['git', 'push']

Thats in the log. Ok so I goto sublime-keymap

  {
    "keys": ["alt+."],
    "command": "git", "args": {"push"}
  },

What am I doing wrong? Does literally no-one else in the world map git push and pull?? Things you type out a ton of times every day. I cant understand why it’s so hard.

0 Likes

#2

If you want to do a git push, you want:

  {
    "keys": ["alt+."],
    "command": "git", "args": {"argv": ["push"]}
  },

Here the command is git, which is the command for executing arbitrary git commands, and argv specifies what arguments you want passed, which here is push.

4 Likes

#3

Thanks for that. Much appreciated. So while that seems to be the correct syntax, I don’t believe it actually works.

After making the change I can see the log file trying to invoke git.

image

However, there is no output, no errors, no change and nothing is pushed.

A related issue is trying to map "Quick commit (current file)

Quick commit on current file seems to be impossible, as logging output is non-existant. Running Quick Commit produces no logs so I have nothing to map a key too.

My apologies if I sound so negative, but I just don’t understand why it’s so difficult. And I’ve yet to see a single instance anywhere on the internet that says this is possible.
It just seems bizarre quite frankly as 1) Git is popular. 2) Sublime is popular 3) Using keyboard shortcuts is popular.

0 Likes

#4

Oh sorry, I thought you were asking about Sublime Merge (where that key binding will indeed work).

If you’re using a Git package of some kind, then you’d have to consult the readme of the package to determine what commands it allows you to bind.

0 Likes

#5

Hah all good. I came across a lot of posts about SublimeMerge before too.

Nope no packages… just built in Git with ST3. I started with the assumption I’m an idiot… but the more I research and google it just doesnt seem possible. Can’t quite why on earth it shouldnt be possible or why its so hard to do such a simple, popular thing.

0 Likes

#6

The only built in Git support in ST3 is read only and shows you what files are modified; If you have commands in the command palette that purport to take git operations, you have a package of some sort installed.

1 Like

#7

Oh boy… thank you so much. You see, I was an idiot after all :joy:

So… I guess I installed this package called Git and assumed it was official. https://packagecontrol.io/packages/Git

Instead it seems like a 3rd party package. I also google ST3 native support and an offical article came up but I didn’t read it too carefully so figured it was all good.

Anyway, mystery solved. Much appreciated for the help

0 Likes

#8

There’s a package called GitSavvy for ST3 thats ok, though I can’t get it to do some things (getting it to talk to gitlab is beyond my capabilities at the moment) so I have to push from the command line (to remote repo) but it does have a lot of nice other functionality… I use it all the time. Don’t know is it works in ST4 (ST)

0 Likes