Chuyển đến nội dung
Skillpedia
Lập trình chung48k · #4733

git-advanced-workflows

Skill này làm gì

Công cụ này giúp sắp xếp và dọn dẹp lịch sử dự án, nhanh chóng tìm lỗi, và làm việc trên nhiều phần của dự án cùng lúc mà không bị lạc.

Khi nào nên dùng

  • ✓Khi bạn muốn sắp xếp các thay đổi trước khi gửi đi.
  • ✓Khi cần tìm thay đổi nào đã gây ra một vấn đề.
  • ✓Khi bạn muốn làm nhiều tác 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-advanced-workflows/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-advanced-workflows/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

“Làm thế nào để dọn dẹp lịch sử 5 commit gần nhất của tôi, sắp xếp lại thông điệp và gộp một số thay đổi?”

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

Cách hoạt động

Nó dùng các lệnh Git nâng cao để viết lại lịch sử, áp dụng các thay đổi cụ thể giữa các dự án, và tìm lỗi trong các phiên bản cũ. Điều này tạo ra một bản ghi gọn gàng và dễ hiểu hơn.

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 Advanced Workflows

Master advanced Git techniques to maintain clean history, collaborate effectively, and recover from any situation with confidence.

Do not use this skill when

  • The task is unrelated to git advanced workflows
  • You need a different domain or tool outside this scope

Instructions

  • Clarify goals, constraints, and required inputs.
  • Apply relevant best practices and validate outcomes.
  • Provide actionable steps and verification.

When to Use

  • Cleaning up commit history before merging
  • Applying specific commits across branches
  • Finding commits that introduced bugs
  • Working on multiple features simultaneously
  • Recovering from Git mistakes or lost commits
  • Managing complex branch workflows
  • Preparing clean PRs for review
  • Synchronizing diverged branches

Repository and Recovery Boundary

Read repository instructions and branch protection first. A hotfix follows the protected PR/maintainer path when required; urgency does not authorize a direct default-branch commit or push. Preserve dirty and staged work before checkout, rebase, reset or restore. A backup branch protects committed history only, not uncommitted files. Inspect exact targets before destructive operations and obtain authorization for shared-history rewrites. Reflog availability depends on local expiry and garbage collection; it cannot guarantee recovery of every lost file.

Core Concepts

1. Interactive Rebase

Interactive rebase is the Swiss Army knife of Git history editing.

Common Operations:

  • pick: Keep commit as-is
  • reword: Change commit message
  • edit: Amend commit content
  • squash: Combine with previous commit
  • fixup: Like squash but discard message
  • drop: Remove commit entirely

Basic Usage:

# Rebase last 5 commits
git rebase -i HEAD~5

# Rebase all commits on current branch
git rebase -i $(git merge-base HEAD main)

# Rebase onto specific commit
git rebase -i abc123

2. Cherry-Picking

Apply specific commits from one branch to another without merging entire branches.

# Cherry-pick single commit
git cherry-pick abc123

# Cherry-pick range of commits (exclusive start)
git cherry-pick abc123..def456

# Cherry-pick without committing (stage changes only)
git cherry-pick -n abc123

# Cherry-pick and edit commit message
git cherry-pick -e abc123

3. Git Bisect

Binary search through commit history to find the commit that introduced a bug.

# Start bisect
git bisect start

# Mark current commit as bad
git bisect bad

# Mark known good commit
git bisect good v1.0.0

# Git will checkout middle commit - test it
# Then mark as good or bad
git bisect good  # or: git bisect bad

# Continue until bug found
# When done
git bisect reset

Automated Bisect:

# Use script to test automatically
git bisect start HEAD v1.0.0
git bisect run ./test.sh

# test.sh should exit 0 for good, 1-127 (except 125) for bad

4. Worktrees

Work on multiple branches simultaneously without stashing or switching.

# List existing worktrees
git worktree list

# Add new worktree for feature branch
git worktree add ../project-feature feature/new-feature

# Add worktree and create new branch
git worktree add -b bugfix/urgent ../project-hotfix main

# Remove worktree
git worktree remove ../project-feature

# Prune stale worktrees
git worktree prune

5. Reflog

Your safety net - tracks all ref movements, even deleted commits.

# View reflog
git reflog

# View reflog for specific branch
git reflog show feature/branch

# Restore deleted commit
git reflog
# Find commit hash
git checkout abc123
git branch recovered-branch

# Restore deleted branch
git reflog
git branch deleted-branch abc123

Practical Workflows

Workflow 1: Clean Up Feature Branch Before PR

# Start with feature branch
git checkout feature/user-auth

# Interactive rebase to clean history
git rebase -i main

# Example rebase operations:
# - Squash "fix typo" commits
# - Reword commit messages for clarity
# - Reorder commits logically
# - Drop unnecessary commits

# Force push cleaned branch (safe if no one else is using it)
git push --force-with-lease origin feature/user-auth

Workflow 2: Apply Hotfix to Multiple Releases

# Create fix on an authorized topic branch from the current target
git fetch origin main
git switch -c hotfix/security origin/main
git commit -m "fix: critical security patch"

# Apply to release branches

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

'Interactive rebase' là gì?

Đây là cách chỉnh sửa và sắp xếp lại các commit (bản lưu thay đổi) trước khi người khác nhìn thấy, cho phép bạn gộp, đổi tên hoặc xóa commit.

'Cherry-pick' là gì?

Đây giống như sao chép một thay đổi cụ thể từ nơi này sang nơi khác trong dự án, mà không cần di chuyển các thay đổi khác đi cùng.

'Git bisect' là gì?

Đây là công cụ tìm kiếm thông minh trong lịch sử dự án để tìm chính xác thay đổi nào đã gây ra lỗi.

Chi tiết

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

Master advanced Git techniques to maintain clean history, collaborate effectively, and recover from any situation with confidence.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4733
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ự