Git adalah version control yang wajib dikuasai developer. Artikel ini membahas workflow Git dari branching sampai resolve conflict.
Branching Strategy

Branch Dasar
# Buat branch baru
git checkout -b feature/login
# Switch branch
git checkout main
# List semua branch
git branch -a
Merge vs Rebase
| Aspek | Merge | Rebase |
|---|---|---|
| Mempertahankan history | Ya (merge commit) | Tidak (linear) |
| Safe untuk shared branch | Ya | Tidak |
| History rapi | Bisa berantakan | Linear |
# Merge
git checkout main
git merge feature/login
# Rebase (hati-hati!)
git checkout feature/login
git rebase main
Resolve Conflict
Conflict terjadi saat dua branch mengubah baris yang sama:
<<<<<<< HEAD
const theme = "dark";
=======
const theme = "light";
>>>>>>> feature/dark-mode
Pilih salah satu atau gabungkan, lalu:
git add .
git rebase --continue # atau: git merge --continue
Best Practices
- Commit kecil dan sering, bukan satu commit besar
- Gunakan
.gitignoreuntuk file yang tidak perlu - Tulis commit message yang deskriptif
- Jangan rebase branch yang sudah di-push dan dipakai orang lain
Tip: Gunakan
git stashuntuk menyimpan perubahan sementara tanpa commit.



