Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)48k · #4741

git-workflow-and-versioning

Skill này làm gì

Hướng dẫn này chỉ bạn cách tổ chức công việc lập trình bằng Git, một hệ thống quản lý phiên bản. Nó giúp bạn lưu tiến độ tại các 'điểm lưu' (commit), làm việc trong các 'hộp cát' riêng (nhánh), và giữ lịch sử rõ ràng về những gì đã làm.

Khi nào nên dùng

  • ✓Khi bắt đầu làm một tính năng mới.
  • ✓Khi thực hiện các thay đổi mã nhỏ.
  • ✓Khi bạn cần tổ chức công việc của nhiều người hoặc nhiều nhiệm vụ cùng lúc.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/git-workflow-and-versioning/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/git-workflow-and-versioning/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi nên lưu tiến độ mã của mình như thế nào để có thể quay lại nếu có sự cố?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Git cho phép bạn lưu công việc theo từng giai đoạn (commit). Mỗi commit giống như một điểm lưu. Nếu bạn mắc lỗi, bạn có thể dễ dàng quay lại commit trước đó. Làm việc trong 'nhánh' cho phép bạn tạo các phiên bản mã riêng để thử nghiệm hoặc làm tính năng khác mà không ảnh hưởng đến mã chính.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Git Workflow and Versioning

Overview

Git is your safety net. Treat commits as save points, branches as sandboxes, and history as documentation. With AI agents generating code at high speed, disciplined version control is the mechanism that keeps changes manageable, reviewable, and reversible.

When to Use

Always. Every code change flows through git.

Core Principles

Trunk-Based Development (Recommended)

Keep main always deployable. Work in short-lived feature branches that merge back within 1-3 days. Long-lived development branches are hidden costs — they diverge, create merge conflicts, and delay integration. DORA research consistently shows trunk-based development correlates with high-performing engineering teams.

main ──●──●──●──●──●──●──●──●──●──  (always deployable)
        ╲      ╱  ╲    ╱
         ●──●─╱    ●──╱    ← short-lived feature branches (1-3 days)

This is the recommended default. Teams using gitflow or long-lived branches can adapt the principles (atomic commits, small changes, descriptive messages) to their branching model — the commit discipline matters more than the specific branching strategy.

  • Dev branches are costs. Every day a branch lives, it accumulates merge risk.
  • Release branches are acceptable. When you need to stabilize a release while main moves forward.
  • Feature flags > long branches. Prefer deploying incomplete work behind flags rather than keeping it on a branch for weeks.

1. Commit Early, Commit Often

Each successful increment gets its own commit. Don't accumulate large uncommitted changes.

Work pattern:
  Implement slice → Test → Verify → Commit → Next slice

Not this:
  Implement everything → Hope it works → Giant commit

Commits are save points. If the next change breaks something, you can revert to the last known-good state instantly.

2. Atomic Commits

Each commit does one logical thing:

# Good: Each commit is self-contained
git log --oneline
a1b2c3d Add task creation endpoint with validation
d4e5f6g Add task creation form component
h7i8j9k Connect form to API and add loading state
m1n2o3p Add task creation tests (unit + integration)

# Bad: Everything mixed together
git log --oneline
x1y2z3a Add task feature, fix sidebar, update deps, refactor utils

3. Descriptive Messages

Commit messages explain the why, not just the what:

# Good: Explains intent
feat: add email validation to registration endpoint

Prevents invalid email formats from reaching the database.
Uses Zod schema validation at the route handler level,
consistent with existing validation patterns in auth.ts.

# Bad: Describes what's obvious from the diff
update auth.ts

Format:

<type>: <short description>

<optional body explaining why, not what>

Types:

  • feat — New feature
  • fix — Bug fix
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests
  • docs — Documentation only
  • chore — Tooling, dependencies, config

4. Keep Concerns Separate

Don't combine formatting changes with behavior changes. Don't combine refactors with features. Each type of change should be a separate commit — and ideally a separate PR:

# Good: Separate concerns
git commit -m "refactor: extract validation logic to shared utility"
git commit -m "feat: add phone number validation to registration"

# Bad: Mixed concerns
git commit -m "refactor validation and add phone number field"

Separate refactoring from feature work. A refactoring change and a feature change are two different changes — submit them separately. This makes each change easier to review, revert, and understand in history. Small cleanups (renaming a variable) can be included in a feature commit at reviewer discretion.

5. Size Your Changes

Target ~100 lines per commit/PR. Changes over ~1000 lines should be split. See the splitting strategies in code-review-and-quality for how to break down large changes.

~100 lines  → Easy to review, easy to revert
~300 lines  → Acceptable for a single logical change
~1000 lines → Split into smaller changes

Branching Strategy

Feature Branches

main (always deployable)
  │
  ├── feature/task-creation    ← One feature per branch
  ├── feature/user-settings    ← Parallel work
  └── fix/duplicate-tasks      ← Bug fixes
  • Branch from main (or the team's default branch)

…

Câu hỏi thường gặp

'Commit' là gì?

Commit là một 'điểm lưu' cho mã của bạn. Nó ghi lại các thay đổi bạn đã làm tại một thời điểm cụ thể, giống như lưu trò chơi.

'Branch' là gì?

Nhánh giống như một bản sao riêng của mã, nơi bạn có thể làm tính năng mới hoặc sửa lỗi mà không ảnh hưởng đến phiên bản chính. Sau đó bạn có thể gộp các thay đổi trở lại.

Vì sao nên commit nhỏ và thường xuyên?

Commit nhỏ, thường xuyên giúp dễ theo dõi những gì đã thay đổi, hiểu lịch sử và quay lại phiên bản trước nếu có sự cố. Giống như lưu trò chơi thường xuyên thay vì chỉ lưu khi kết thúc.

Chi tiết

Mô tả gốc của tác giả

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4741
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự