Sublime Forum

Amend commit keyboard shortcut?

#1

I want to be able to stage all changes quickly and to commit --amend a previous commit. Finally I want to do a push --force.

Is there a keyboard shortcut sequence I can use for this?

So, the equivalent of:

git add . && git commit --amend --no-edit && git push --force
1 Like

#2

You can define keybindings the same way as for Sublime Text.

So …

  1. Main Menu > Preferences > Browse Packages …
  2. Navigate to the User package.
  3. Create a Default.sublime-keymap file if not yet extists.
  4. Add the binding.
[
    //
    // Commit Dialog
    //

    {
        "keys": ["ctrl+shift+enter"],
        "command": "commit",
        "args": { "mode": "commit --amend" },
        "context": [
            { "key": "setting.commit_message" },
            { "key": "can_commit" }
        ]
    },
]
4 Likes

#3

Nice!

And sorry to hijack but on Windows this suffers from the same problem as e.g. Ctrl-Enter for editing commit messages: on keyboards with both Return and Enter key, it actually only works for Ctrl-Return. Would there be a way to fix that?

0 Likes

#4

I’m not sure what you mean by having both a Return and Enter key, but in case it helps the Enter/Return key that’s associated with the numeric keypad area of the keyboard can be bound with keypad_enter instead of enter (which represents the Enter/Return key in the more traditional location above the right Shift key).

0 Likes

#5

Thanks, yes that’s what I meant essentially, both ‘Enter/Return’ key above right shift and an ‘Enter’ key lower right in numeric keypad. So keypad_enter works indeed for the latter, but a bit tedious to have to add that for all commands using Enter.

0 Likes