DEV Community

ohmygod
ohmygod

Posted on

GitBrew: A Smart Git Workflow Assistant Built with GitHub Copilot CLI

This is a submission for the GitHub Copilot CLI Challenge

What I Built

GitBrew is a developer productivity tool that supercharges your Git workflow by combining GitHub Copilot CLI with custom shell automation. It turns complex, multi-step Git operations into simple natural language commands.

Ever found yourself googling "how to rebase interactively and squash the last 5 commits" for the 100th time? GitBrew solves that. It's a wrapper around Git that uses Copilot CLI to interpret what you want to do and translates it into the exact Git commands β€” then executes them safely with confirmation prompts.

Key Features

  • 🍺 Natural Language Git β€” Type gitbrew "undo my last 3 commits but keep the changes" and it figures out the right commands
  • πŸ” Smart Conflict Resolution β€” When merge conflicts arise, GitBrew uses Copilot to explain each conflict and suggest resolutions
  • πŸ“‹ Commit Message Generation β€” Analyzes your staged changes and generates conventional commit messages
  • 🌳 Branch Strategy Advisor β€” Suggests branching strategies based on your project's history and team patterns
  • πŸ›‘οΈ Safety Net β€” Every destructive operation shows a preview and requires confirmation. Undo history for the last 10 operations
  • πŸ“Š Workflow Analytics β€” Tracks your most common Git patterns and suggests aliases

Demo

GitHub Repository: github.com/ohmygod/gitbrew

Installation

npm install -g gitbrew
# Requires GitHub Copilot CLI to be installed and authenticated
gh auth login
gh extension install github/gh-copilot
Enter fullscreen mode Exit fullscreen mode

Example Session

$ gitbrew "I accidentally committed secrets to the last commit, help"

🍺 GitBrew analyzing your request...
πŸ“‹ Copilot suggests the following plan:

  1. git reset --soft HEAD~1     # Undo last commit, keep changes staged
  2. # Remove secret files from staging
  3. echo "*.env" >> .gitignore  # Add to gitignore
  4. git add .gitignore
  5. git commit -m "chore: update gitignore to exclude env files"

⚠️  This will modify your commit history. Continue? [y/N] y
βœ… Done! Secret files removed from Git history.
πŸ’‘ Tip: Consider using git-secrets or pre-commit hooks to prevent this in the future.
Enter fullscreen mode Exit fullscreen mode
$ gitbrew "show me what changed this week across all branches"

🍺 GitBrew analyzing your request...
πŸ“Š Activity Report (Jan 26 - Feb 2, 2026):

  main:    3 commits (+247 / -89 lines)
  feature: 12 commits (+1,203 / -456 lines) 
  hotfix:  1 commit (+3 / -3 lines)

  Top files changed: src/api/routes.ts (8 changes)
  Most active contributor: @ohmygod (16 commits)
Enter fullscreen mode Exit fullscreen mode
$ gitbrew commit

🍺 Analyzing staged changes...
πŸ“ Suggested commit message:

  feat(auth): add OAuth2 PKCE flow for mobile clients

  - Implement PKCE challenge/verifier generation
  - Add token exchange endpoint
  - Update auth middleware to handle mobile sessions
  - Add integration tests for PKCE flow

Use this message? [Y/n/edit] y
βœ… Committed: feat(auth): add OAuth2 PKCE flow for mobile clients
Enter fullscreen mode Exit fullscreen mode

My Experience with GitHub Copilot CLI

GitHub Copilot CLI was the backbone of this entire project β€” not just as a feature of GitBrew, but as my primary development tool while building it.

How Copilot CLI Powers GitBrew

At its core, GitBrew pipes user requests through gh copilot suggest and gh copilot explain to generate Git command sequences. The magic is in the prompt engineering:

const { execSync } = require("child_process");

function askCopilot(userIntent, context) {
  const prompt = `Given a git repository with the following state:
    - Current branch: ${context.branch}
    - Uncommitted changes: ${context.hasChanges}
    - Last 5 commits: ${context.recentCommits}

    The user wants to: ${userIntent}

    Provide the exact git commands needed, one per line.`;

  return execSync(`gh copilot suggest -t shell "${prompt}"`, 
    { encoding: "utf-8" });
}
Enter fullscreen mode Exit fullscreen mode

How Copilot CLI Helped Me Build GitBrew

  1. Rapid Prototyping β€” I used gh copilot suggest constantly to figure out Node.js patterns I wasn't familiar with, like building interactive CLI prompts with Inquirer.js

  2. Shell Script Generation β€” The trickiest part was writing cross-platform shell scripts for Git operations. Copilot CLI generated POSIX-compliant scripts that work on macOS, Linux, and WSL

  3. Test Writing β€” gh copilot explain helped me understand edge cases in Git's behavior (like detached HEAD states), which I then turned into test cases

  4. Documentation β€” The README, man pages, and inline help text were all drafted with Copilot CLI and refined by hand

Impact on Development Speed

What would have taken me 3-4 weeks of evenings and weekends took about 10 days. The biggest time-saver was Copilot CLI's ability to explain complex Git internals β€” instead of diving into documentation, I could ask "explain what happens to the reflog when I do an interactive rebase" and get an immediate, actionable answer.

The meta aspect is fun too: I used an AI CLI tool to build a tool that uses AI CLI. It's turtles all the way down. 🐒


GitBrew is open source under the MIT license. PRs welcome!

Top comments (0)