README-auto-commit

快速說明:tools/auto_commit.ps1
目的

  • 讀取已 staged 的 git diff,透過 OpenAI API 生成合適的 commit 訊息,並執行 git commit
    使用前準備
  1. 在 PowerShell 設定你的 OpenAI API key:
    $env:OPENAI_API_KEY = '你的_api_key_here'
    
  2. 確認已將要提交的檔案加入 staged:
    git add <files>
    
    使用方法
  3. 在 repo 根目錄執行:
    powershell -File .\tools\auto_commit.ps1
    
  4. 腳本會顯示 AI 生成的 commit 訊息,並詢問是否要執行提交(輸入 y 確認)。
    注意事項
  • 這個腳本範例使用 OpenAI 的 chat/completions API。你可以根據自己的 AI 提供者修改 $ApiUrlmodel
  • 若你想改用 GitHub Copilot CLI(若已安裝),可改為呼叫 Copilot CLI 產生訊息,然後再由腳本執行 commit。
  • 請保護你的 API key,不要把它放入版本控制。

Also See

File2FileLast Modified
Json工具推薦Json工具推薦1:25 AM - December 07, 2025
PasteBin快速分享純文字內容PasteBin快速分享純文字內容8:21 PM - December 06, 2025