Skip to main content
Photo of DeepakNess DeepakNess

Keybindings to stage, commit, and sync at once

Unproofread notes

Came across this tweet that provides a keybinding to automatically stage, generate AI commit message, commit, and sync with GitHub inside Cursor (below, I added the VS Code version as well). Not much, it's going to save 10-20 seconds each time you push your code.

Keybindings for Cursor AI

{
    "key":"ctrl+enter",
    "command":"runCommands",
    "args":{
        "commands":[
        {
            "command":"git.stageAll"
        },
        {
            "command":"cursor.generateGitCommitMessage"
        },
        {
            "command":"git.commitAll"
        },
        {
            "command":"git.sync"
        }
        ]
    }
}

To use this, press cmd+shift+p on macOS or ctrl+shift+p on Windows and type "Preferences: Open Keyboard Shortcuts (JSON)". It opens a file called keybindings.json where you have to add the above JSON code (do not delete the existing code though).

My entire keybindings.json file looks something like this:

// Place your key bindings in this file to override the defaults
[
    {
        "key": "cmd+i",
        "command": "composerMode.agent"
    },
    {
        "key":"ctrl+enter",
        "command":"runCommands",
        "args":{
            "commands":[
            {
                "command":"git.stageAll"
            },
            {
                "command":"cursor.generateGitCommitMessage"
            },
            {
                "command":"git.commitAll"
            },
            {
                "command":"git.sync"
            }
            ]
        }
    }
]

Keybindings for Copilot in VS Code

If you're using GitHub Copilot in VS Code, then the JSON would be like this:

{
    "key":"ctrl+enter",
    "command":"runCommands",
    "args":{
        "commands":[
        {
            "command":"git.stageAll"
        },
        {
            "command":"github.copilot.git.generateCommitMessage"
        },
        {
            "command":"git.commitAll"
        },
        {
            "command":"git.sync"
        }
        ]
    }
}

And then when you press ctrl+enter while being inside Cursor or VS Code, it automatically stages all changes, generates AI commit messages, commits, and then pushes to GitHub within seconds.

Comment via email