Prompt file imported from blinkihc/retribusi-report (
.windsurf/workflows/git-workflow.md). Copyright stays with the author.
Git Workflow
Workflow ini menjelaskan best practices untuk bekerja dengan Git dalam project ini.
1. Sebelum Mulai Bekerja
Selalu pull perubahan terbaru dari remote repository:
git pull origin main
Atau jika menggunakan branch lain:
git pull origin <nama-branch>
2. Membuat Branch Baru
Untuk fitur baru atau bug fix, buat branch baru:
git checkout -b feature/<nama-fitur>
Atau untuk bug fix:
git checkout -b fix/<nama-bug>
Contoh penamaan branch:
feature/add-payment-reportfix/calculation-errorrefactor/optimize-queries
3. Melakukan Perubahan
Cek Status File
git status
Stage Perubahan
Stage file tertentu:
git add <nama-file>
Stage semua perubahan:
git add .
Commit Perubahan
Gunakan commit message yang jelas dan deskriptif:
git commit -m "feat: add payment report feature"
Format commit message yang disarankan:
feat:untuk fitur barufix:untuk bug fixrefactor:untuk refactoring codedocs:untuk perubahan dokumentasistyle:untuk perubahan formattingtest:untuk menambah atau update testschore:untuk maintenance tasks
4. Push ke Remote
Push branch ke remote repository:
git push origin <nama-branch>
Jika pertama kali push branch baru:
git push -u origin <nama-branch>
5. Membuat Pull Request
- Buka repository di GitHub/GitLab
- Klik "New Pull Request" atau "Create Merge Request"
- Pilih branch yang ingin di-merge
- Isi deskripsi PR dengan detail perubahan
- Request review dari team member
- Tunggu approval dan merge
6. Update Branch dengan Main
Jika main branch sudah ada update baru sementara kamu masih bekerja di branch:
git checkout main
git pull origin main
git checkout <nama-branch-kamu>
git merge main
Atau menggunakan rebase (lebih clean history):
git checkout <nama-branch-kamu>
git rebase main
7. Mengatasi Konflik
Jika terjadi konflik saat merge/rebase:
- Buka file yang konflik
- Cari marker konflik (
<<<<<<<,=======,>>>>>>>) - Pilih perubahan yang ingin dipertahankan
- Hapus marker konflik
- Stage file yang sudah diperbaiki:
git add <file-yang-konflik> - Lanjutkan merge/rebase:
ataugit merge --continuegit rebase --continue
8. Membatalkan Perubahan
Unstage file (sebelum commit)
git reset HEAD <nama-file>
Buang perubahan di working directory
git checkout -- <nama-file>
Undo commit terakhir (keep changes)
git reset --soft HEAD~1
Undo commit terakhir (discard changes)
git reset --hard HEAD~1
9. Melihat History
Lihat commit history:
git log
Lihat history dengan format compact:
git log --oneline --graph --all
10. Stash Changes
Simpan perubahan sementara tanpa commit:
git stash
Lihat daftar stash:
git stash list
Apply stash terakhir:
git stash pop
Apply stash tertentu:
git stash apply stash@{n}
Best Practices
- Commit Often: Commit perubahan kecil secara berkala
- Clear Messages: Gunakan commit message yang jelas dan deskriptif
- Pull Before Push: Selalu pull sebelum push untuk menghindari konflik
- Branch Strategy: Gunakan branch untuk setiap fitur atau bug fix
- Review Code: Selalu review code sebelum merge
- Test Before Commit: Pastikan code berjalan dengan baik sebelum commit
- Keep Main Clean: Jangan commit langsung ke main branch
- Sync Regularly: Sync branch dengan main secara berkala
Troubleshooting
Lupa nama branch
git branch -a
Lihat perubahan sebelum commit
git diff
Lihat perubahan yang sudah di-stage
git diff --staged
Hapus branch lokal
git branch -d <nama-branch>
Hapus branch remote
git push origin --delete <nama-branch>