← Back|SOFTWARE-ENGINEERINGSection 1/17
0 of 17 completed

Git + AI workflows

Intermediate13 min read📅 Updated: 2026-02-17

Introduction

Git use pannama coding panradhu — save illama game vilayadaradhu maari! 🎮 AI era la Git even more important — yaen na AI generate panna code ah track, review, and manage pannanum.


AI + Git combination properly use panna — unga workflow 10x faster aagum. Mess up panna — merge conflict hell la maattiduvenga! 😈


Indha article la AI-powered Git workflows, best practices, and real-world strategies cover pannrom! 🔀✨

AI Code ku Branching Strategy

🏗️ Architecture Diagram
AI code ku recommended branching model:

```
main (production ready)
  │
  ├── develop (integration branch)
  │     │
  │     ├── feature/ai-auth-system
  │     │     ├── ai-generated (AI raw output)
  │     │     ├── human-reviewed (after review)
  │     │     └── tested (after tests pass)
  │     │
  │     ├── feature/ai-dashboard
  │     │     ├── ai-generated
  │     │     ├── human-reviewed
  │     │     └── tested
  │     │
  │     └── hotfix/ai-bug-fix
  │
  └── release/v2.0
```

**Key Rule:** AI generate panna code **separate commits** la irukkanum — later enna AI wrote, enna human wrote nu track pannalam! 📊

```bash
# AI code ku specific prefix use pannunga
git commit -m "ai: generate user authentication module"
git commit -m "review: fix AI auth edge cases"
git commit -m "test: add auth integration tests"
```

AI-Powered Commit Messages

AI kitta meaningful commit messages generate panna sollunga:


bash
# Option 1: Git diff ah AI ku feed pannunga
git diff --staged | pbcopy
# Then paste to AI: "Write a conventional commit message for this diff"

# Option 2: Use AI CLI tools
# GitHub Copilot CLI
gh copilot suggest "commit message for this change"

# Option 3: Custom script
#!/bin/bash
DIFF=$(git diff --staged)
echo "Generate conventional commit message for:\n$DIFF" | ai-cli

Good vs Bad AI Commit Messages:


❌ Bad (AI Default)✅ Good (AI + Human)
"Update files""feat(auth): add JWT refresh token rotation"
"Fix bug""fix(cart): handle zero quantity edge case"
"Add code""feat(ai): integrate GPT-4 for recommendations"
"Changes""refactor(db): optimize user query with index"

Conventional Commits format follow pannunga:

type(scope): description


Types: feat, fix, docs, style, refactor, test, chore 📝

AI-Assisted Code Review

PR review la AI tools use pannunga:


bash
# AI ku PR diff feed pannunga
gh pr diff 42 | ai-review

# Or use GitHub Actions
# .github/workflows/ai-review.yml
name: AI Code Review
on: [pull_request]
jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: coderabbitai/ai-pr-reviewer@latest
        with:
          review_level: detailed

AI Code Review Checklist:


CheckWhat AI FindsWhat Humans Check
**Bugs**Common patterns, typosBusiness logic errors
**Security**Known vulnerabilitiesAuth flow correctness
**Performance**O(n²) patternsReal-world bottlenecks
**Style**Formatting, namingArchitecture decisions
**Tests**Missing test casesTest meaningfulness

Best Practice: AI review first, then human review. AI catches mechanical issues — humans catch design issues! 🤖👤

AI Files ku .gitignore Setup

AI tools create pannum files ah properly gitignore pannunga:


gitignore
# .gitignore — AI specific entries

# AI conversation logs
.ai-history/
.copilot-logs/
*.ai-chat

# AI generated drafts (not reviewed)
*.ai-draft.*
.ai-output/

# API keys (AI services)
.env.ai
.openai-key
.anthropic-key

# AI model caches
.model-cache/
__ai_cache__/

# Cursor/Copilot workspace settings
.cursor/
.copilot/

# But DO track these!
# !.ai-config.json  ← AI tool settings team share pannunga

Important Rules:

  • ❌ API keys never commit pannaadheenga
  • ❌ AI conversation history commit pannaadheenga (sensitive info irukkum)
  • ✅ AI tool configs commit pannunga (team consistency)
  • ✅ AI-generated code (after review) commit pannunga 🔐

Git Hooks + AI Automation

Git hooks use panni AI code quality automate pannunga:


bash
# .husky/pre-commit
#!/bin/sh

echo "🤖 AI Code Quality Check..."

# 1. Lint AI-generated files
npx eslint --fix $(git diff --staged --name-only -- '*.ts' '*.js')

# 2. Check for hardcoded API keys
if git diff --staged | grep -iE '(api[_-]?key|secret|password)\s*[:=]\s*["']'; then
  echo "🚨 Possible API key detected! Remove before committing."
  exit 1
fi

# 3. Run tests for changed files
npx jest --findRelatedTests $(git diff --staged --name-only)

# 4. AI-assisted commit message suggestion
echo "💡 Suggested commit message:"
git diff --staged --stat

bash
# .husky/pre-push
#!/bin/sh

echo "🔍 Pre-push AI code validation..."

# Full test suite
npm test

# Security audit
npm audit --production

# Type check
npx tsc --noEmit

echo "✅ All checks passed!"

Hooks setup pannina — bad AI code accidentally push aagadhu! 🛡️

Interactive Rebase for AI Commits

AI use panni code write panna messy commit history varum. Clean up pannunga:


bash
# Last 5 commits clean up pannunga
git rebase -i HEAD~5

# Example: AI code generate + fix + fix + test + cleanup
# Before:
pick a1b2c3 ai: generate user service
pick d4e5f6 fix: AI forgot null check
pick g7h8i9 fix: another AI bug
pick j1k2l3 test: add user tests
pick m4n5o6 cleanup: remove AI comments

# After (squash related commits):
pick a1b2c3 ai: generate user service
squash d4e5f6 fix: AI forgot null check
squash g7h8i9 fix: another AI bug
pick j1k2l3 test: add user tests
squash m4n5o6 cleanup: remove AI comments

Result: Clean history with 2 meaningful commits instead of 5 messy ones!


BeforeAfter
5 scattered commits2 clean commits
"fix AI bug" messagesMeaningful descriptions
Hard to reviewEasy to understand

Clean Git history = happy team = easy debugging! ✨

Git Blame + AI Attribution

💡 Tip

AI-generated code track panna git blame use pannunga:

bash
# Who wrote this line? (AI or human?)
git blame src/auth.ts

# AI commits filter pannunga
git log --oneline --grep="^ai:" -- src/auth.ts

# AI vs Human code ratio check
git log --oneline --grep="^ai:" | wc -l    # AI commits
git log --oneline --grep="^review:" | wc -l # Review commits

Convention: Commit prefix use pannunga:

- ai: — AI generated code

- review: — Human review fixes

- test: — Test additions

- refactor: — Human refactoring of AI code

Idha follow panna — any time enna AI wrote, enna human wrote nu track pannalam! 📊

Cherry Pick AI Code Across Branches

AI generate panna useful code ah other branches la reuse pannunga:


bash
# Scenario: AI feature/ai-utils branch la useful helper generate pannuchu
# Main branch la also venum

# 1. Find the commit
git log feature/ai-utils --oneline --grep="ai: add string utils"
# Output: abc1234 ai: add string utils

# 2. Cherry pick to current branch
git cherry-pick abc1234

# 3. If conflict varudhu
git cherry-pick abc1234
# CONFLICT! Resolve manually:
git status
# Edit conflicting files
git add .
git cherry-pick --continue

# 4. Multiple AI commits pick pannunga
git cherry-pick abc1234 def5678 ghi9012

Pro Tip: AI generate panna reusable utilities separate branch la maintain pannunga — any project la cherry-pick pannalam! 🍒

Git Stash for AI Experiments

AI kitta multiple approaches try pannunga — stash use pannunga:


bash
# Approach 1: AI generated REST API
# ... code looks okay, stash it
git stash push -m "ai-approach-1: REST API"

# Approach 2: AI generated GraphQL API
# ... code also looks okay, stash it
git stash push -m "ai-approach-2: GraphQL API"

# Compare both approaches
git stash list
# stash@{0}: ai-approach-2: GraphQL API
# stash@{1}: ai-approach-1: REST API

# Try approach 1
git stash apply stash@{1}
# Test it...

# Not good? Switch to approach 2
git checkout -- .
git stash apply stash@{0}
# Test it...

# Winner found! Clean up
git stash drop stash@{1}  # Remove loser
git stash drop stash@{0}  # Remove applied winner

Stash use panna — AI approaches safely experiment pannalam without losing anything! 🧪

GitHub Actions for AI Code Pipeline

Complete CI/CD pipeline AI code ku:


yaml
# .github/workflows/ai-code-pipeline.yml
name: AI Code Pipeline

on:
  pull_request:
    branches: [main, develop]

jobs:
  ai-code-quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: 🤖 Detect AI-generated files
        run: |
          AI_FILES=$(git log --diff-filter=A --name-only --grep="^ai:" HEAD~5..HEAD)
          echo "AI generated files: $AI_FILES"
          echo "AI_FILES=$AI_FILES" >> $GITHUB_ENV

      - name: 🔍 Extra linting for AI code
        run: npx eslint $AI_FILES --max-warnings 0

      - name: 🧪 Run related tests
        run: npx jest --findRelatedTests $AI_FILES --coverage

      - name: 🔐 Security scan
        run: npx snyk test

      - name: 📊 Coverage gate
        run: |
          COVERAGE=$(npx jest --coverage --json | jq '.coverageMap')
          echo "Coverage report generated"

      - name: ✅ AI Code Approved
        if: success()
        run: echo "All AI code checks passed!"

Pipeline pass aanaa dhaan merge! No exceptions! 🚦

Monorepo la AI Code Management

Example

Monorepo la AI-generated code organize pannunga:

code
my-project/
├── packages/
│   ├── core/           ← Human-written core logic
│   ├── ai-services/    ← AI-generated service layer
│   ├── ai-utils/       ← AI-generated utilities
│   └── shared/         ← Shared types/interfaces
├── .ai-manifest.json   ← Track AI-generated files
└── .github/
    └── CODEOWNERS      ← Extra review for AI dirs

code
# CODEOWNERS
# AI-generated code needs senior review
packages/ai-services/ @senior-devs @tech-lead
packages/ai-utils/ @senior-devs

json
// .ai-manifest.json — Track what AI generated
{
  "aiGenerated": [
    {"file": "packages/ai-services/auth.ts", "model": "gpt-4", "date": "2026-02-17"},
    {"file": "packages/ai-utils/string.ts", "model": "claude", "date": "2026-02-15"}
  ]
}

Organized monorepo = clear ownership = quality control! 📂

Key Takeaways

Feature branch per AI task — never main branch ku direct commit pannaadheenga, review venum


Conventional commits followai: prefix AI-generated, review: human fixes, test: additions use pannunga


AI review → Human review — AI mechanical issues find pannum, humans design decisions verify pannunga


Pre-commit hooks enforce — lint, format, tests, security scan — manual discipline always fail, automation better


Track AI-generated code — .ai-manifest.json maintain, enna AI generate pannu enna human write pannu clear ah


API keys never commit — pre-commit hooks scan, .gitignore setup, environment variables use pannunga


Interactive rebase clean history — AI-generated scattered commits squash, meaningful commit history maintain pannunga


Cherry-pick code reuse — useful AI utility different branches cherry-pick pannalam, duplication avoid pannunga

Pro Tips Reference

💡 Tip

Git + AI Workflow Pro Tips:

🔀 Branching: Feature branch per AI task — never commit to main directly

📝 Commits: Use ai: prefix for AI-generated, review: for human fixes

🔍 Review: AI review first, then human review — catch different issues

🧪 Testing: Pre-commit hooks enforce tests before push

📊 Tracking: .ai-manifest.json maintain pannunga — who wrote what

🔐 Security: Pre-commit hook scan for API keys

🧹 Cleanup: Interactive rebase for clean history

🍒 Reuse: Cherry-pick useful AI code across branches

Follow these — unga Git history clean, traceable, and professional ah irukkum! ✨

🏁 Mini Challenge

Challenge: Setup Complete Git + AI Workflow


Oru project Git + AI best practices setup pannunga (45 mins):


  1. Repository: New repo create pannunga or existing select pannunga
  2. Branching: Feature branch create panni AI code generate panni
  3. Commit: AI-generated code ai: prefix with commit panni
  4. Hooks: Pre-commit hook setup panni (lint, format, tests, security scan)
  5. CODEOWNERS: AI-generated dirs specify panni review require panni
  6. Manifest: .ai-manifest.json create panni AI-generated files track panni
  7. Review: PR process follow panni human review get panni merge panni

Tools: Git, GitHub/GitLab, Husky for hooks, ESLint, pytest/Jest


Deliverable: Production-ready repo with clean AI-integrated history 🚀

Interview Questions

Q1: AI-generated code commits epdi track panna best – special naming convention?

A: Yes! ai: prefix use panni – "ai: Add payment processing API with Claude", then PR description la which AI tool, which parts manual. Tracking important for auditing and debugging later.


Q2: AI code review process traditional code review different aa?

A: Yes significantly! AI code review: functionality, security, performance, edge cases check panni first. Then traditional review: architecture, design patterns, team standards alignment. Two-phase approach better.


Q3: GitHub CODEOWNERS AI-generated code sections la use panna benefits?

A: CODEOWNERS AI-generated dirs require panni senior approval automatically enforce pannum. Code quality gate add pannum, knowledge sharing ensure pannum, risk mitigation pannum.


Q4: Pre-commit hooks AI workflows la necessary aa?

A: Critical! Hooks ensure lint pass, tests pass, no API keys committed, code formatting consistent. AI code deploy panradhu munnadhi automatic checks catch panra issues prevent pannum.


Q5: Git history la AI-generated code track panna long-term importance enna?

A: Compliance, auditing, debugging. "Who wrote this?" answer pannalam AI-generated or human. Future refactoring decisions, performance issues investigation – history provide panra context essential.

Frequently Asked Questions

AI generate panna code ku separate branch venum ah?
Yes! Always separate feature branch la work pannunga. AI code directly main branch la commit pannaadheenga — review and test first.
AI commit messages generate pannalama?
Yes, AI useful commit messages generate pannum. But always review pannunga — AI sometimes too generic messages write pannum. Context add pannunga.
Git conflicts AI code la eppdi handle panradhu?
AI tools like GitHub Copilot merge conflicts resolve panna help pannum. But always manually verify pannunga — AI wrong resolution suggest pannalam.
🧠Knowledge Check
Quiz 1 of 1

AI-generated code ku best Git practice enna?

0 of 1 answered