当前位置: 首页 > news >正文

Claude Code Git Commit Push 命令

Claude Code Git Commit & Push 命令

介绍

输入 /git:commit-push 指令,就能完成 代码变更分析、标准化 commit message 生成、提交文件并推送到远程仓库 的全自动流程。
它遵循 Conventional Commits 规范,支持自动检测 commit 类型(feat、fix、docs、style、refactor、test、chore),也可手动指定类型并附加说明。

内置变更分析、冲突检测、规范检查、远程验证等安全机制,让你告别繁琐的手动提交,一条命令高效完成提交与推送。

存放位置

~/.claude/commands/git/commit-push.md

注意事项

可根据需求进行适当调整。

Git Commit & Push 命令


description: Automatically generate commit message, commit changes, and push to remote repository
argument-hint: [commit-type] [optional-message]
allowed-tools: [Bash, Grep, LS, Read]

Git Commit and Push

Automatically analyzes code changes, generates a standardized commit message following conventional commits format, commits the changes, and pushes to the remote repository.

Usage:

/git:commit-push [commit-type] [optional-message]

Arguments:

  • commit-type (optional): Type of commit (feat, fix, docs, style, refactor, test, chore). If not provided, will be auto-detected based on changes.
  • optional-message (optional): Additional message to append to the generated commit message.

Process:

  1. Check git status to ensure there are changes to commit
  2. Analyze staged and unstaged changes using git diff
  3. Determine commit type based on file changes if not provided
  4. Generate conventional commit message (lowercase, max 70 chars)
  5. Add unstaged files to staging area
  6. Commit with generated message including Claude Code attribution
  7. Push changes to remote repository
  8. Provide feedback on the operation status

Examples:

  • /git:commit-push - Auto-detect type and generate commit message
  • /git:commit-push feat - Force commit type to “feat”
  • /git:commit-push fix "resolve login issue" - Use “fix” type with custom message
  • /git:commit-push docs - Document changes commit

Commit Type Detection Rules:

  • feat: New features (new files, major functionality additions)
  • fix: Bug fixes (modifications in src/, lib/, or core files)
  • docs: Documentation (README, .md files, comments)
  • style: Code formatting, semicolons, etc. (no logic changes)
  • refactor: Code restructuring without changing functionality
  • test: Adding or modifying tests
  • chore: Build process, dependencies, tooling changes

Generated Commit Message Format:

type: brief description of changes

The commit message will be generated in the same language style as the project’s existing commits. For this project, it will use Chinese descriptions following the pattern seen in recent commits.

Examples:

  • feat: 添加用户认证系统
  • fix: 修复数据处理中的内存泄漏
  • docs: 更新API文档

Error Handling:

  • Validates that we’re in a git repository
  • Checks for uncommitted changes
  • Handles merge conflicts
  • Provides clear error messages for common issues
  • Ensures remote repository is accessible before pushing

Notes:

  • Follows project convention of lowercase commit messages with 70 character limit
  • Automatically includes Claude Code attribution in commit body
  • Skips push if remote tracking branch is not set up
  • Provides detailed feedback on each step of the process
  • Handles both staged and unstaged files appropriately
http://www.dtcms.com/a/341593.html

相关文章:

  • 大模型4位量化 (46)
  • linux内核源码下载
  • CMOS知识点 MOS管不同工作区域电容特性
  • SED项目复现学习实录
  • Linux基础介绍-3——第一阶段
  • oracle服务器导入dmp文件
  • 力扣 hot100 Day79
  • ragflow 通过HuggingFace 配置rerank模型
  • 有序二叉树的删除
  • leetcode 3 无重复字符的最长子串
  • 个人使用AI开发的《PlSqlRewrite4GaussDB(PLSQL自动转换工具)1.0.1 BETA》发布
  • 【OneAI】使用Rust构建的轻量AI网关
  • linux环境问题
  • HyperMesh许可证分配优化策略
  • 【Ansible】变量、机密、事实
  • 福昕PDF编辑软件高级版下载与详细图文安装教程!!
  • Pub/Sub是什么意思
  • LWIP的Socket API 与实现关系
  • c#入门笔记(3)
  • 图像数据增强的高效执行
  • Linux下运行Jmeter压测
  • Kafka如何保证「消息不丢失」,「顺序传输」,「不重复消费」,以及为什么会发生重平衡(reblanace)
  • 攻克PostgreSQL专家认证
  • Git Commit 提交信息标准格式
  • Python打卡Day47 注意力热图可视化
  • 字符设备驱动、块设备驱动和网络设备驱动
  • Gitee仓库 日常操作详细步骤
  • Linux服务器性能优化总结
  • 【数据结构】快速排序算法精髓解析
  • shell脚本——搜索某个目录下带指定前缀的文件