Apa Itu Git dan GitHub?
Git adalah version control system (VCS) yang digunakan untuk melacak perubahan kode. GitHub adalah platform hosting repository Git yang juga menyediakan fitur kolaborasi, issue tracking, CI/CD, dan lainnya. Git dan GitHub adalah tools wajib bagi setiap developer.
Mengapa Git & GitHub Wajib?
- Version Control – Lacak setiap perubahan kode
- Kolaborasi – Kerja tim dengan branch dan merge
- Backup – Kode tersimpan di cloud
- Portfolio – GitHub profile sebagai portfolio
- Open Source – Kontribusi ke project open source
- CI/CD – GitHub Actions untuk automation
Konsep Dasar Git
- Repository – Folder project yang di-track Git
- Commit – Snapshot perubahan kode
- Branch – Jalur pengembangan paralel
- Merge – Menggabungkan branch
- Pull Request – Request untuk merge kode
- Clone – Copy repository dari remote
- Push/Pull – Upload/download perubahan
- Staging Area – Area persiapan sebelum commit
Perintah Git Dasar
# Konfigurasi awal
git config --global user.name "Nama Anda"
git config --global user.email "email@example.com"
# Membuat repository
git init # Init di folder existing
git clone URL # Clone dari remote
# Workflow dasar
git status # Cek status
git add . # Stage semua file
git add file.txt # Stage file tertentu
git commit -m "Pesan commit" # Commit
git push origin main # Push ke remote
git pull origin main # Pull dari remote
# Branch
git branch # List branch
git branch nama-branch # Buat branch baru
git checkout nama-branch # Pindah branch
git checkout -b nama-branch # Buat dan pindah
git merge nama-branch # Merge branch
git branch -d nama-branch # Hapus branch
# History
git log # Lihat history
git log --oneline # History singkat
git diff # Lihat perubahan
git diff --staged # Lihat staged changes
# Undo
git reset HEAD file.txt # Unstage file
git checkout -- file.txt # Discard changes
git revert commit-hash # Revert commit
git reset --soft HEAD~1 # Undo last commit (keep changes)
git reset --hard HEAD~1 # Undo last commit (discard changes)
# Stash
git stash # Simpan perubahan sementara
git stash pop # Kembalikan perubahan
git stash list # List stash
# Remote
git remote -v # List remote
git remote add origin URL # Tambah remote
git fetch origin # Fetch dari remote
Git Workflow (Git Flow)
- main/master – Branch produksi (stable)
- develop – Branch pengembangan
- feature/* – Branch fitur baru
- hotfix/* – Branch perbaikan urgent
- release/* – Branch persiapan release
GitHub Features
- Repository – Hosting kode
- Issues – Bug tracking dan feature request
- Pull Requests – Code review dan merge
- Actions – CI/CD automation
- Projects – Kanban board
- Wiki – Dokumentasi
- Pages – Static site hosting
- Packages – Package registry
Tips Belajar Git & GitHub
- Praktik setiap hari – Commit kode setiap hari
- Gunakan branch – Jangan commit langsung ke main
- Tulis commit message yang jelas – Gunakan conventional commits
- Pelajari Git Flow – Workflow standar industri
- Kontribusi ke open source – Fork, clone, PR
- Gunakan GitHub CLI – gh command
- Baca Git documentation – git-scm.com
Tools yang Dibutuhkan
| Tool | Deskripsi |
|---|---|
| Git | Version control system |
| GitHub Account | Platform hosting |
| GitHub Desktop | GUI untuk Git |
| VS Code | Code editor dengan Git integration |
| GitKraken / SourceTree | GUI Git client |
Kesimpulan
Git dan GitHub adalah tools wajib bagi setiap developer. Dengan menguasai version control, kolaborasi, dan open source contribution, Anda akan menjadi developer yang lebih profesional.
“Git is a tool that tracks changes in your code over time.” – Git Community




