You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改GitHub提交时自动填充的默认commit message?

GitHub网页端提交默认信息自定义说明

GitHub官方暂未开放网页端提交代码时的默认commit信息自定义配置,原生功能无法直接修改默认提示内容,可通过以下方式实现你需要的效果:

  • 使用浏览器用户脚本自动替换默认内容
    可以安装Tampermonkey、Violentmonkey这类浏览器脚本管理插件,编写简单的规则匹配网页端提交输入框的默认值,自动替换为你需要的格式。以下是适配你的需求的脚本示例:
    // ==UserScript==
    // @name         GitHub Commit 信息替换
    // @version      0.1
    // @match        *://github.com/*/*/new/*
    // @match        *://github.com/*/*/edit/*
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
        const observer = new MutationObserver(() => {
            const commitInput = document.querySelector('#commit-summary-input');
            if (commitInput && commitInput.value === 'Create README.md') {
                commitInput.value = '📝 Create README';
                observer.disconnect();
            }
        });
        observer.observe(document.body, { childList: true, subtree: true });
    })();
    
    安装插件后新建脚本粘贴上述代码保存即可生效,你也可以自行扩展匹配规则,适配更多提交场景的默认信息替换。
  • 本地Git提交自定义模板方案
    如果你日常也使用本地Git工具提交代码,可以配置全局commit模板实现自定义默认提交提示,仅对本地提交生效,不会影响GitHub网页端:
    # 创建全局commit模板文件
    touch ~/.git_commit_template
    # 编辑该文件写入你需要的默认提交内容
    # 配置Git全局加载该模板
    git config --global commit.template ~/.git_commit_template
    

内容的提问来源于stack exchange,提问作者Sakhund

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 19:24:04