safe-git-rebase
Skill1 starsChanged 45 days agoMITView on GitHub
Quy trình Git Rebase chuẩn mực, an toàn tuyệt đối (Fail-Safe Git Rebase Flow). Hướng dẫn đồng bộ code từ origin/main hoặc origin/uat vào nhánh feature bằng Rebase, xử lý conflict, hủy khẩn cấp và push an toàn với --force-with-lease.
- Deletes or force-pushes
- Commits and pushes
In this repository83 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- adopt-repoSkill
- agent-strict-guardSkill
- analyze-featureSkill
- backend-api-design-flowSkill
- clean-code-naming-conventionsSkill
- code-review-gateSkill
- dangerous-action-blockerSkill
- database-transaction-managementSkill
- db-interface-procedure-flowSkill
- db-migrationSkill
- defensive-troubleshooting-guideSkill
- git-workflowSkill
- human-authority-overrideSkill
- human-master-mapSkill
- implement-featureSkill
- jpa-n-plus-one-optimizationSkill
- knowledge-graphSkill
- multi-language-error-handlingSkill
- post-code-verificationSkill
- project-doctorSkill
- project-governance-dashboardSkill
- redis-cache-patternsSkill
- release-notesSkill
- security-secret-scannerSkill
- speckit-analyzeSkill
- speckit-auditSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-helpSkill
- speckit-implementSkill
- speckit-ingestSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- spec-writerSkill
- spring-middleware-pipelineSkill
- sql-repository-patternSkill
- system-dna-managerSkill
- test-featureSkill
- adopt-repoSkill
- agent-strict-guardSkill
- analyze-featureSkill
- backend-api-design-flowSkill
- clean-code-naming-conventionsSkill
- code-review-gateSkill
- dangerous-action-blockerSkill
- database-transaction-managementSkill
- db-interface-procedure-flowSkill
- db-migrationSkill
- defensive-troubleshooting-guideSkill
- git-workflowSkill
- human-authority-overrideSkill
- human-master-mapSkill
- implement-featureSkill
- jpa-n-plus-one-optimizationSkill
- knowledge-graphSkill
- multi-language-error-handlingSkill
- The first 60 shown.
The file
Files
<!-- GENERATED FROM registry/skills/safe-git-rebase/SKILL.md — DO NOT EDIT DIRECTLY --><!-- GENERATED FROM .shared/skills/02-codestyle/safe-git-rebase/SKILL.md — DO NOT EDIT DIRECTLY -->Quy Trình Git Rebase An Toàn Tuyệt Đối (Fail-Safe Git Rebase Flow)
Tài liệu này cung cấp quy trình chuẩn hóa từng bước để thực hiện git rebase cập nhật mã nguồn mới nhất từ nhánh origin/main (hoặc origin/uat) vào nhánh tính năng (feature/...), đảm bảo lịch sử commit thẳng tắp (Linear History), tránh commit merge rác và bảo toàn 100% an toàn dữ liệu.
🛑 3 Quy Tắc Vàng Sống Còn (The Golden Rules of Rebase)
[!CAUTION]
- CHỈ Rebase trên nhánh cá nhân (
feature/.../agent/...): Tuyệt đối KHÔNG BAO GIỜ rebase trên các nhánh dùng chung (main,uat,master).- LUÔN tạo nhánh Backup trước khi rebase: Đảm bảo có đường lui khẩn cấp trong mọi tình huống.
- LUÔN dùng
--force-with-leasekhi push: Tuyệt đối không dùnggit push -fmù quáng để tránh vô tình ghi đè code của đồng nghiệp.
🔄 Quy Trình 6 Bước Rebase Chuẩn Mực
(Code mới của đồng nghiệp trên main)
origin/main: A --- B --- C --- D
\
feature (Sau rebase): E' --- F' (Commit của bạn nằm trên đỉnh)Bước 1: Đảm bảo Working Tree sạch sẽ
Trước khi rebase, toàn bộ thay đổi phải được commit hoặc stash:
git status
# Nếu còn file đang sửa dở:
git stash save "temp-wip-before-rebase"Bước 2: Tạo nhánh Backup phòng hộ (Bắt buộc)
# Cú pháp: git branch backup-<tên-nhánh>-<ngày>
git branch backup-feature-branchBước 3: Lấy dữ liệu mới nhất từ remote
git fetch origin mainBước 4: Thực hiện Rebase lên origin/main
git rebase origin/mainTình huống A: Thành công mượt mà (Không có conflict)
Git hiển thị: Successfully rebased and updated refs/heads/feature/...
-> Chuyển thẳng sang Bước 5.
Tình huống B: Bị xung đột mã nguồn (Conflict)
- Mở file conflict trên IDE, chọn code đúng (
Accept Current ChangehoặcAccept Incoming Changehoặc kết hợp). - Đánh dấu file đã giải quyết conflict:
git add <đường_dẫn_file_đã_sửa> - Tiếp tục rebase:
git rebase --continue
[!IMPORTANT] CẢNH BÁO: Khi giải quyết conflict trong quá trình rebase, TUYỆT ĐỐI KHÔNG gõ
git commit. Chỉ dùnggit addrồigit rebase --continue.
Bước 5: Kiểm tra chất lượng sau Rebase
Trước khi push, kiểm tra xem code có bị lỗi cú pháp hay hỏng test không:
./gradlew test # hoặc mvn testBước 6: Đẩy code lên Remote an toàn (--force-with-lease)
git push origin <tên-nhánh-feature> --force-with-lease🆘 Cẩm Nang Cứu Hộ Khẩn Cấp (Disaster Recovery)
Cách 1: Hủy ngay lệnh Rebase đang chạy dở
git rebase --abort(Mọi thứ lập tức hoàn nguyên 100% về trước khi rebase).
Cách 2: Khôi phục từ nhánh Backup đã tạo ở Bước 2
git reset --hard backup-feature-branchCách 3: Hồi sinh bằng git reflog
git reflog
# Tìm dòng trước khi rebase (ví dụ: HEAD@{3})
git reset --hard HEAD@{3}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

