Git Command Snippet.
Snippet Singkat untuk membuat belajar git
Last updated: 4 days ago
🔹 Git Command Snippets
1. Setup Awal
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --list
2. Repo Baru & Clone
git init # inisialisasi repo baru
git clone <url> # clone repo dari remote
3. Status & Log
git status # cek status repo
git log # riwayat commit
git log --oneline --graph --all
4. Add & Commit
git add . # tambah semua perubahan
git add <file> # tambah file tertentu
git commit -m "pesan" # buat commit
git commit --amend # ubah commit terakhir
5. Branching
git branch # lihat daftar branch
git branch <nama> # buat branch baru
git checkout <nama> # pindah branch
git checkout -b <nama> # buat + pindah branch
git merge <nama> # merge branch lain ke current
6. Remote & Push/Pull
git remote -v # lihat remote
git remote add origin <url>
git push -u origin main # push pertama kali
git push # push perubahan
git pull # ambil update terbaru
7. Undo / Reset
git restore <file> # batalin perubahan di file
git restore --staged <file> # unstaged
git reset --hard HEAD # balik ke kondisi commit terakhir
git reset --hard <hash> # balik ke commit tertentu
8. Stash
git stash # simpan perubahan sementara
git stash pop # kembalikan perubahan
git stash list # lihat daftar stash
9. Tagging
git tag v1.0.0 # buat tag
git tag # lihat daftar tag
git push origin v1.0.0 # push tag