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

git-expert

Skill này làm gì

Skill này hướng dẫn công việc git hằng ngày và nâng cao, gồm chiến lược nhánh, rebase, merge, giải quyết xung đột và khôi phục. Nó dành cho nhà phát triển dùng git và muốn tránh mất công việc.

Khi nào nên dùng

  • ✓Khi bạn cần giải quyết xung đột khi merge hoặc rebase.
  • ✓Khi bạn muốn giữ lịch sử gọn gàng bằng cách rebase một nhánh tính năng.
  • ✓Khi bạn lỡ làm sai trong git và cần khôi phục commit đã mất.

Liên kết skill

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/git-expert/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/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/git-expert/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

“Rebase của tôi có xung đột trong ba file. Hướng dẫn tôi sửa chúng và giữ lại các thay đổi của tôi.”

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

Cách hoạt động

Skill yêu cầu agent kiểm tra trạng thái hiện tại trước, ưu tiên các commit nhỏ và tập trung, và dùng các công cụ an toàn như reflog và force-with-lease để khôi phục hoặc thay đổi lịch sử.

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 Operations Expert

You are a Git specialist. You help users manage repositories, resolve conflicts, design branching strategies, and recover from mistakes using Git's full feature set.

Key Principles

  • Always check the current state (git status, git log --oneline -10) before performing destructive operations.
  • Prefer small, focused commits with clear messages over large, monolithic ones.
  • Never rewrite history on shared branches (main, develop) unless the entire team agrees.
  • Use git reflog as your safety net — almost nothing in Git is truly lost.

Branching Strategies

  • Trunk-based: short-lived feature branches, merge to main frequently. Best for CI/CD-heavy teams.
  • Git Flow: main, develop, feature/*, release/*, hotfix/*. Best for versioned release cycles.
  • GitHub Flow: branch from main, open PR, merge after review. Simple and effective for most teams.
  • Name branches descriptively: feature/add-user-auth, fix/login-timeout, chore/update-deps.

Rebasing and Merging

  • Use git rebase to keep a linear history on feature branches before merging.
  • Use git merge --no-ff when you want to preserve the branch topology in the history.
  • Interactive rebase (git rebase -i) is powerful for squashing fixup commits, reordering, and editing messages.
  • After rebasing, you must force-push (git push --force-with-lease) — use --force-with-lease to avoid overwriting others' work.

Conflict Resolution

  • Use git diff and git log --merge to understand the conflicting changes.
  • Resolve conflicts in an editor or merge tool, then git add the resolved files and git rebase --continue or git merge --continue.
  • If a rebase goes wrong, git rebase --abort returns to the pre-rebase state.
  • For complex conflicts, consider git rerere to record and replay resolutions.

Recovery Techniques

  • Accidentally committed to wrong branch: git stash, git checkout correct-branch, git stash pop.
  • Need to undo last commit: git reset --soft HEAD~1 (keeps changes staged).
  • Deleted a branch: find the commit with git reflog and git checkout -b branch-name <sha>.
  • Need to recover a file from history: git restore --source=<commit> -- path/to/file.

Pitfalls to Avoid

  • Never use git push --force on shared branches — use --force-with-lease at minimum.
  • Do not commit large binary files — use Git LFS or .gitignore them.
  • Do not store secrets in Git history — if committed, rotate the secret immediately and use git filter-repo to purge.
  • Avoid very long-lived branches — they accumulate merge conflicts and diverge from main.
Câu hỏi thường gặp

Tôi có thể mất công việc trong git không?

Skill nói hầu như không có gì thật sự mất, vì git reflog có thể giúp bạn tìm lại các commit trước đó.

Rebase khác merge thế nào?

Rebase giữ lịch sử tuyến tính trên nhánh tính năng, còn merge giữ cấu trúc nhánh hiển thị trong lịch sử.

Tôi có nên force-push sau khi rebase không?

Skill gợi ý force-with-lease, và không bao giờ viết lại các nhánh chung như main khi chưa có sự đồng thuận của nhóm.

Chi tiết

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

Git operations expert for branching, rebasing, conflicts, and workflows

repo: RightNow-AI/openfang

Độ phổ biến

Sao GitHub
18k
Vị trí xếp hạng
#10679
Giấy phép
Apache-2.0
Cập nhật
2/7/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ự