How to change Github's default commit messages?
Asked Answered
I

4

5

I've been wondering is it possible to change the message that appears in the input field when you commit on Github. Refer to the picture below:

enter image description here

I like my commits to be as descriptive as possible and enjoyable to read. I want Github to suggest 📝 Create README instead of Create README.md.

When I search for the solution, the 'google search' shows irrelevant answers. Is it somehow possible?

Note: This does not answer my question.

Indicator answered 6/12, 2021 at 22:10 Comment(2)
Why does it matter what GitHub suggests if you write your own descriptive message anyway?Innervate
I change that default suggestion(the message that commits when you don't type anything) every time and I'd like to make my life easier.Indicator
D
7

If you can do this at all, it certainly won't be easy. The GitHub web interface is proprietary software that does not provide a setting for you to make this change. You might be able to create a UserScript in your browser using TamperMonkey (or similar) that detects the fields on the page and modifies them, but you'll have to write all the logic and then keep changing it whenever GitHub makes changes to their code.

Note that your suggested commit message that contains emoji is not actually more descriptive than their default message, in fact many people will find it less readable.

Disposal answered 6/12, 2021 at 22:19 Comment(2)
Oh, that's a shame. But thanks for the suggestion though. Good idea for a side-project. Lastly, thanks for the note. @Moshe KatzIndicator
wasn't that hard, took me maybe 10 minutes. you're right about maintenance thoughDimer
D
3

With a userscript-manager such as Greasemonkey, Violentmonkey, or Tampermonkey, this is easily scriptable. My personal favorite is Violentmonkey (because Greasemonkey is unmaintained, and Tampermonkey is closed-source. Violentmonkey is open-source and maintained)

For example, in Violentmonkey:

// ==UserScript==
// @name        New script - github.com
// @namespace   Violentmonkey Scripts
// @match       https://github.com/*
// @grant       none
// @version     1.0
// @author      -
// @description 10/3/2023, 11:38:45 AM
// ==/UserScript==
(function () {
    let changerIntervalId = null;
    const changer = function () {
        let ele = document.querySelector("#\\:rb\\:");
        if (!ele) {
            return;
        }
        if (!ele.placeholder || !ele.value) {
            // uninitialized
            return;
        }
        if (ele.placeholder === "Create README.md") {
            ele.placeholder = "📝Create README";
        }
        if (ele.value === "Create README.md") {
            ele.value = "📝Create README";
        }
        // my job here is done
        clearInterval(changerIntervalId);
    };
    changerIntervalId = setInterval(changer, 1000);
})();

changes the default "Create README.md" to "📝Create README".

Dimer answered 3/10, 2023 at 10:4 Comment(0)
S
0

When you tap commit change, you can tap in to the top rectangle and tap backspace or other keyword to change the default value.

Switchman answered 5/10, 2023 at 1:6 Comment(1)
I think OP wants to change the default that will be used for future commits, not to edit the default every timeBract
C
0

It's not easy to update or edit the message by default. this is the message is written by Git IDE default, actually, we want to write a default message when we commit to GitHub, we can use a .sh (on Mac) or .bat (on Windows) script to implement the feature, that is easier to implement than update the GIT IDE

Czardom answered 5/10, 2023 at 1:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.