Langsung ke konten
Skillpedia
Deploy & cloud (DevOps)107k Β· #773

git-workflow-and-versioning

Fungsinya

Alat ini membantu mengatur kode yang Anda dan AI buat. Alat ini mengajarkan Anda untuk sering menyimpan kemajuan (commit), mengerjakan bagian kode yang terpisah (branch), dan memberi nama yang jelas pada bagian-bagian tersebut, sehingga semuanya tetap rapi dan mudah diperbaiki jika terjadi kesalahan.

Kapan dipakai

  • βœ“Setiap kali Anda atau AI membuat perubahan kode.
  • βœ“Saat menyimpan kemajuan (commit) atau membuat jalur kerja baru (branch).
  • βœ“Saat Anda perlu mengatur beberapa tugas berbeda sekaligus.

Link skill

https://github.com/addyosmani/agent-skills/blob/main/skills/git-workflow-and-versioning/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/addyosmani/agent-skills/blob/main/skills/git-workflow-and-versioning/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBagaimana cara menyimpan pekerjaan saya saat ini ke dalam 'versi' baru yang teratur?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

AI menyarankan untuk sering menyimpan bagian pekerjaan kecil, seperti 'titik simpan'. Setiap penyimpanan (commit) sebaiknya hanya melakukan satu hal yang logis dan memiliki pesan yang menjelaskan alasannya, bukan hanya apa yang dilakukan.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

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)

…

Pertanyaan umum

Apa itu 'commit'?

'Commit' seperti titik simpan dalam proyek Anda. Commit mencatat sekumpulan perubahan pada kode, sehingga Anda bisa kembali ke versi tersebut jika diperlukan.

Apa itu 'branch'?

'Branch' seperti salinan terpisah dari proyek Anda, tempat Anda bisa mengerjakan ide baru atau perbaikan tanpa memengaruhi versi utama. Ini adalah ruang aman untuk bereksperimen.

Mengapa penting menyimpan pekerjaan secara sering?

Menyimpan secara sering (atomic commits) mencegah Anda kehilangan pekerjaan dan memudahkan Anda menemukan serta memperbaiki masalah. Jika ada yang rusak, Anda bisa dengan mudah kembali ke titik simpan sebelumnya yang masih berfungsi.

Detail

Deskripsi asli dari pembuat

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging,

repo: addyosmani/agent-skills

Popularitas

Bintang GitHub
107k
Peringkat
#773
Lisensi
MIT
Diperbarui
13/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa