GIT DOCS
SETUP-CONFIG
Name
Description
Example
Output
git config --global user.nameDescription: Set nama pengguna global.
Example:
git config --global user.name "Ridho Akbar"
Output: Nama tersimpan
git config --global user.nameSet nama pengguna global.
git config --global user.name "Ridho Akbar"
Nama tersimpan
git config --global user.emailDescription: Set email pengguna global.
Example:
git config --global user.email "ridho@email.com"
Output: Email tersimpan
git config --global user.emailSet email pengguna global.
git config --global user.email "ridho@email.com"
Email tersimpan
git config --listDescription: Lihat semua konfigurasi Git.
Example:
git config --list
Output: user.name=Ridho...
git config --listLihat semua konfigurasi Git.
git config --list
user.name=Ridho...
git config --global init.defaultBranchDescription: Set default branch name (main).
Example:
git config --global init.defaultBranch main
Output: Default: main
git config --global init.defaultBranchSet default branch name (main).
git config --global init.defaultBranch main
Default: main
git config --global core.editorDescription: Set editor default untuk commit message.
Example:
git config --global core.editor "code --wait"
Output: VS Code
git config --global core.editorSet editor default untuk commit message.
git config --global core.editor "code --wait"
VS Code
git config --global core.autocrlfDescription: Atur line ending (true=Windows, input=Mac/Linux).
Example:
git config --global core.autocrlf true
Output: CRLF auto
git config --global core.autocrlfAtur line ending (true=Windows, input=Mac/Linux).
git config --global core.autocrlf true
CRLF auto
git config --global alias.<shortcut>Description: Buat shortcut perintah.
Example:
git config --global alias.co checkout
Output: git co = git checkout
git config --global alias.<shortcut>Buat shortcut perintah.
git config --global alias.co checkout
git co = git checkout
git config --global --editDescription: Edit global config file langsung.
Example:
git config --global --edit
Output: Buka .gitconfig
git config --global --editEdit global config file langsung.
git config --global --edit
Buka .gitconfig
INIT-CLONE
Name
Description
Example
Output
git initDescription: Inisialisasi repo Git baru di folder.
Example:
git init
Output: Initialized empty Git repository
git initInisialisasi repo Git baru di folder.
git init
Initialized empty Git repository
git init -b <branch>Description: Inisialisasi dengan branch tertentu.
Example:
git init -b main
Output: Branch: main
git init -b <branch>Inisialisasi dengan branch tertentu.
git init -b main
Branch: main
git clone <url>Description: Clone repo dari remote.
Example:
git clone https://github.com/user/repo.git
Output: Folder repo terdownload
git clone <url>Clone repo dari remote.
git clone https://github.com/user/repo.git
Folder repo terdownload
git clone <url> <folder>Description: Clone ke folder spesifik.
Example:
git clone https://github.com/user/repo.git my-project
Output: Folder: my-project
git clone <url> <folder>Clone ke folder spesifik.
git clone https://github.com/user/repo.git my-project
Folder: my-project
git clone --branch <branch> <url>Description: Clone branch tertentu saja.
Example:
git clone --branch dev https://github.com/user/repo.git
Output: Branch dev
git clone --branch <branch> <url>Clone branch tertentu saja.
git clone --branch dev https://github.com/user/repo.git
Branch dev
git clone --depth 1 <url>Description: Shallow clone — hanya commit terbaru (lebih cepat).
Example:
git clone --depth 1 https://github.com/user/repo.git
Output: Ukuran kecil
git clone --depth 1 <url>Shallow clone — hanya commit terbaru (lebih cepat).
git clone --depth 1 https://github.com/user/repo.git
Ukuran kecil
git clone --single-branch <url>Description: Clone hanya 1 branch.
Example:
git clone --single-branch --branch main <url>
Output: 1 branch saja
git clone --single-branch <url>Clone hanya 1 branch.
git clone --single-branch --branch main <url>
1 branch saja
BASIC-SNAPSHOT
Name
Description
Example
Output
git statusDescription: Cek status working directory & staging area.
Example:
git status
Output: modified: file.txt
git statusCek status working directory & staging area.
git status
modified: file.txt
git status -sDescription: Status singkat (short).
Example:
git status -s
Output: M file.txt
git status -sStatus singkat (short).
git status -s
M file.txt
git add <file>Description: Tambahkan file ke staging area.
Example:
git add index.html
Output: Staged
git add <file>Tambahkan file ke staging area.
git add index.html
Staged
git add .Description: Tambahkan semua perubahan ke staging.
Example:
git add .
Output: Semua staged
git add .Tambahkan semua perubahan ke staging.
git add .
Semua staged
git add -ADescription: Tambahkan semua termasuk delete.
Example:
git add -A
Output: Semua (add, modify, delete)
git add -ATambahkan semua termasuk delete.
git add -A
Semua (add, modify, delete)
git add -pDescription: Tambahkan perubahan secara interaktif (patch).
Example:
git add -p
Output: Pilih hunk per hunk
git add -pTambahkan perubahan secara interaktif (patch).
git add -p
Pilih hunk per hunk
git commit -m "msg"Description: Commit perubahan dengan pesan.
Example:
git commit -m "feat: add login page"
Output: [main a1b2c3d] feat: add login page
git commit -m "msg"Commit perubahan dengan pesan.
git commit -m "feat: add login page"
[main a1b2c3d] feat: add login page
git commit -am "msg"Description: Add + commit sekaligus (hanya file tracked).
Example:
git commit -am "fix: typo"
Output: Staged & committed
git commit -am "msg"Add + commit sekaligus (hanya file tracked).
git commit -am "fix: typo"
Staged & committed
git commit --amendDescription: Ubah commit terakhir (pesan atau isi).
Example:
git commit --amend -m "new message"
Output: Commit terakhir diubah
git commit --amendUbah commit terakhir (pesan atau isi).
git commit --amend -m "new message"
Commit terakhir diubah
git commit --amend --no-editDescription: Tambahkan perubahan ke commit terakhir tanpa ubah pesan.
Example:
git add . && git commit --amend --no-edit
Output: Commit terakhir ditambah
git commit --amend --no-editTambahkan perubahan ke commit terakhir tanpa ubah pesan.
git add . && git commit --amend --no-edit
Commit terakhir ditambah
git commit --allow-emptyDescription: Commit kosong (untuk trigger CI/CD).
Example:
git commit --allow-empty -m "trigger build"
Output: Commit kosong
git commit --allow-emptyCommit kosong (untuk trigger CI/CD).
git commit --allow-empty -m "trigger build"
Commit kosong
git reset <file>Description: Unstage file (keluarkan dari staging).
Example:
git reset index.html
Output: Unstaged
git reset <file>Unstage file (keluarkan dari staging).
git reset index.html
Unstaged
git reset HEAD <file>Description: Unstage file (sintaks lama).
Example:
git reset HEAD file.txt
Output: Unstaged
git reset HEAD <file>Unstage file (sintaks lama).
git reset HEAD file.txt
Unstaged
git restore --staged <file>Description: Unstage file (cara modern).
Example:
git restore --staged file.txt
Output: Unstaged
git restore --staged <file>Unstage file (cara modern).
git restore --staged file.txt
Unstaged
git restore <file>Description: Kembalikan file ke versi terakhir commit (buang perubahan).
Example:
git restore file.txt
Output: Perubahan hilang
git restore <file>Kembalikan file ke versi terakhir commit (buang perubahan).
git restore file.txt
Perubahan hilang
git clean -nDescription: Lihat file untracked yang akan dihapus (dry run).
Example:
git clean -n
Output: Would remove file.txt
git clean -nLihat file untracked yang akan dihapus (dry run).
git clean -n
Would remove file.txt
git clean -fDescription: Hapus file untracked.
Example:
git clean -f
Output: Removing file.txt
git clean -fHapus file untracked.
git clean -f
Removing file.txt
git clean -fdDescription: Hapus file & folder untracked.
Example:
git clean -fd
Output: Removing folder/
git clean -fdHapus file & folder untracked.
git clean -fd
Removing folder/
DIFF-LOG
Name
Description
Example
Output
git diffDescription: Lihat perubahan yang belum di-staging.
Example:
git diff
Output: + baris baru
git diffLihat perubahan yang belum di-staging.
git diff
+ baris baru
git diff --stagedDescription: Lihat perubahan yang sudah di-staging.
Example:
git diff --staged
Output: + baris staged
git diff --stagedLihat perubahan yang sudah di-staging.
git diff --staged
+ baris staged
git diff <commit1> <commit2>Description: Bandingkan dua commit.
Example:
git diff abc123 def456
Output: Perbedaan
git diff <commit1> <commit2>Bandingkan dua commit.
git diff abc123 def456
Perbedaan
git diff <branch1>..<branch2>Description: Bandingkan dua branch.
Example:
git diff main..dev
Output: Perbedaan branch
git diff <branch1>..<branch2>Bandingkan dua branch.
git diff main..dev
Perbedaan branch
git diff --name-onlyDescription: Hanya tampilkan nama file yang berubah.
Example:
git diff --name-only
Output: file1.txt
file2.js
git diff --name-onlyHanya tampilkan nama file yang berubah.
git diff --name-only
file1.txt
file2.js
git logDescription: Lihat riwayat commit.
Example:
git log
Output: commit abc... Author: ...
git logLihat riwayat commit.
git log
commit abc... Author: ...
git log --onelineDescription: Log ringkas 1 baris per commit.
Example:
git log --oneline
Output: a1b2c3d feat: login
git log --onelineLog ringkas 1 baris per commit.
git log --oneline
a1b2c3d feat: login
git log --oneline --graphDescription: Log dengan grafik branch.
Example:
git log --oneline --graph --all
Output: * a1b2c3d (HEAD -> main)
git log --oneline --graphLog dengan grafik branch.
git log --oneline --graph --all
* a1b2c3d (HEAD -> main)
git log -pDescription: Log dengan patch/diff setiap commit.
Example:
git log -p
Output: + baris ditambahkan
git log -pLog dengan patch/diff setiap commit.
git log -p
+ baris ditambahkan
git log --statDescription: Log dengan statistik file berubah.
Example:
git log --stat
Output: 2 files changed, 10 insertions
git log --statLog dengan statistik file berubah.
git log --stat
2 files changed, 10 insertions
git log --author="name"Description: Filter log by author.
Example:
git log --author="Ridho"
Output: Commit Ridho saja
git log --author="name"Filter log by author.
git log --author="Ridho"
Commit Ridho saja
git log --since="date"Description: Log sejak tanggal tertentu.
Example:
git log --since="2025-01-01"
Output: Sejak 2025
git log --since="date"Log sejak tanggal tertentu.
git log --since="2025-01-01"
Sejak 2025
git log -<n>Description: Tampilkan n commit terakhir.
Example:
git log -5
Output: 5 commit terakhir
git log -<n>Tampilkan n commit terakhir.
git log -5
5 commit terakhir
git show <commit>Description: Lihat detail 1 commit.
Example:
git show a1b2c3d
Output: diff + metadata
git show <commit>Lihat detail 1 commit.
git show a1b2c3d
diff + metadata
git blame <file>Description: Lihat siapa yang mengubah setiap baris.
Example:
git blame index.html
Output: a1b2c3d (Ridho 2025-01-01) line
git blame <file>Lihat siapa yang mengubah setiap baris.
git blame index.html
a1b2c3d (Ridho 2025-01-01) line
git shortlogDescription: Ringkasan commit per author.
Example:
git shortlog
Output: Ridho (5): feat: ...
git shortlogRingkasan commit per author.
git shortlog
Ridho (5): feat: ...
BRANCH
Name
Description
Example
Output
git branchDescription: Lihat daftar branch lokal.
Example:
git branch
Output: * main
dev
git branchLihat daftar branch lokal.
git branch
* main
dev
git branch -rDescription: Lihat branch remote.
Example:
git branch -r
Output: origin/main
git branch -rLihat branch remote.
git branch -r
origin/main
git branch -aDescription: Lihat semua branch (lokal + remote).
Example:
git branch -a
Output: Semua branch
git branch -aLihat semua branch (lokal + remote).
git branch -a
Semua branch
git branch <nama>Description: Buat branch baru.
Example:
git branch feature-login
Output: Branch dibuat
git branch <nama>Buat branch baru.
git branch feature-login
Branch dibuat
git checkout <branch>Description: Pindah ke branch (cara lama).
Example:
git checkout dev
Output: Switched to branch 'dev'
git checkout <branch>Pindah ke branch (cara lama).
git checkout dev
Switched to branch 'dev'
git switch <branch>Description: Pindah ke branch (cara modern).
Example:
git switch main
Output: Switched to 'main'
git switch <branch>Pindah ke branch (cara modern).
git switch main
Switched to 'main'
git switch -c <branch>Description: Buat + pindah ke branch baru.
Example:
git switch -c feature- baru
Output: Switched to new branch
git switch -c <branch>Buat + pindah ke branch baru.
git switch -c feature- baru
Switched to new branch
git checkout -b <branch>Description: Buat + pindah (cara lama).
Example:
git checkout -b feature-baru
Output: Switched to new branch
git checkout -b <branch>Buat + pindah (cara lama).
git checkout -b feature-baru
Switched to new branch
git branch -d <branch>Description: Hapus branch lokal (aman — sudah di-merge).
Example:
git branch -d feature-lama
Output: Deleted branch
git branch -d <branch>Hapus branch lokal (aman — sudah di-merge).
git branch -d feature-lama
Deleted branch
git branch -D <branch>Description: Hapus branch lokal (paksa — belum merge).
Example:
git branch -D feature-lama
Output: Deleted branch
git branch -D <branch>Hapus branch lokal (paksa — belum merge).
git branch -D feature-lama
Deleted branch
git branch -m <old> <new>Description: Rename branch.
Example:
git branch -m old-name new-name
Output: Renamed
git branch -m <old> <new>Rename branch.
git branch -m old-name new-name
Renamed
git branch -m <new>Description: Rename branch saat ini.
Example:
git branch -m new-name
Output: Renamed current
git branch -m <new>Rename branch saat ini.
git branch -m new-name
Renamed current
MERGE-REBASE
Name
Description
Example
Output
git merge <branch>Description: Merge branch ke branch saat ini.
Example:
git merge feature-login
Output: Merge made by 'ort' strategy
git merge <branch>Merge branch ke branch saat ini.
git merge feature-login
Merge made by 'ort' strategy
git merge --no-ff <branch>Description: Merge tanpa fast-forward (selalu buat merge commit).
Example:
git merge --no-ff feature
Output: Merge commit dibuat
git merge --no-ff <branch>Merge tanpa fast-forward (selalu buat merge commit).
git merge --no-ff feature
Merge commit dibuat
git merge --squash <branch>Description: Squash semua commit branch jadi 1 sebelum merge.
Example:
git merge --squash feature
Output: Siap di-commit manual
git merge --squash <branch>Squash semua commit branch jadi 1 sebelum merge.
git merge --squash feature
Siap di-commit manual
git merge --abortDescription: Batalkan merge yang sedang conflict.
Example:
git merge --abort
Output: Kembali sebelum merge
git merge --abortBatalkan merge yang sedang conflict.
git merge --abort
Kembali sebelum merge
git rebase <branch>Description: Re-apply commit di atas branch lain (history linear).
Example:
git rebase main
Output: Successfully rebased
git rebase <branch>Re-apply commit di atas branch lain (history linear).
git rebase main
Successfully rebased
git rebase -i <commit>Description: Interactive rebase — squash, reword, drop commit.
Example:
git rebase -i HEAD~3
Output: Editor terbuka
git rebase -i <commit>Interactive rebase — squash, reword, drop commit.
git rebase -i HEAD~3
Editor terbuka
git rebase --continueDescription: Lanjutkan rebase setelah resolve conflict.
Example:
git rebase --continue
Output: Rebase lanjut
git rebase --continueLanjutkan rebase setelah resolve conflict.
git rebase --continue
Rebase lanjut
git rebase --abortDescription: Batalkan rebase.
Example:
git rebase --abort
Output: Kembali sebelum rebase
git rebase --abortBatalkan rebase.
git rebase --abort
Kembali sebelum rebase
git rebase --skipDescription: Lewati commit yang conflict.
Example:
git rebase --skip
Output: Commit dilewati
git rebase --skipLewati commit yang conflict.
git rebase --skip
Commit dilewati
git cherry-pick <commit>Description: Ambil 1 commit dari branch lain ke branch saat ini.
Example:
git cherry-pick a1b2c3d
Output: Commit dipindahkan
git cherry-pick <commit>Ambil 1 commit dari branch lain ke branch saat ini.
git cherry-pick a1b2c3d
Commit dipindahkan
git cherry-pick --continueDescription: Lanjutkan cherry-pick setelah resolve.
Example:
git cherry-pick --continue
Output: Cherry-pick lanjut
git cherry-pick --continueLanjutkan cherry-pick setelah resolve.
git cherry-pick --continue
Cherry-pick lanjut
git cherry-pick --abortDescription: Batalkan cherry-pick.
Example:
git cherry-pick --abort
Output: Kembali
git cherry-pick --abortBatalkan cherry-pick.
git cherry-pick --abort
Kembali
STASH
Name
Description
Example
Output
git stashDescription: Simpan perubahan sementara (working + staging).
Example:
git stash
Output: Saved working directory
git stashSimpan perubahan sementara (working + staging).
git stash
Saved working directory
git stash -m "msg"Description: Stash dengan pesan.
Example:
git stash -m "WIP: login"
Output: Saved with message
git stash -m "msg"Stash dengan pesan.
git stash -m "WIP: login"
Saved with message
git stash -uDescription: Stash termasuk file untracked.
Example:
git stash -u
Output: Termasuk untracked
git stash -uStash termasuk file untracked.
git stash -u
Termasuk untracked
git stash -aDescription: Stash termasuk file ignored.
Example:
git stash -a
Output: Semua
git stash -aStash termasuk file ignored.
git stash -a
Semua
git stash listDescription: Lihat daftar stash.
Example:
git stash list
Output: stash@{0}: WIP on main: ...
git stash listLihat daftar stash.
git stash list
stash@{0}: WIP on main: ...
git stash popDescription: Ambil stash terakhir & hapus dari list.
Example:
git stash pop
Output: Perubahan kembali
git stash popAmbil stash terakhir & hapus dari list.
git stash pop
Perubahan kembali
git stash pop stash@{n}Description: Ambil stash ke-n.
Example:
git stash pop stash@{1}Output: Stash ke-1 kembali
git stash pop stash@{n}Ambil stash ke-n.
git stash pop stash@{1}Stash ke-1 kembali
git stash applyDescription: Ambil stash terakhir TANPA hapus dari list.
Example:
git stash apply
Output: Perubahan kembali, stash tetap ada
git stash applyAmbil stash terakhir TANPA hapus dari list.
git stash apply
Perubahan kembali, stash tetap ada
git stash drop stash@{n}Description: Hapus stash ke-n.
Example:
git stash drop stash@{0}Output: Dropped
git stash drop stash@{n}Hapus stash ke-n.
git stash drop stash@{0}Dropped
git stash clearDescription: Hapus semua stash.
Example:
git stash clear
Output: Semua stash hilang
git stash clearHapus semua stash.
git stash clear
Semua stash hilang
REMOTE
Name
Description
Example
Output
git remoteDescription: Lihat daftar remote.
Example:
git remote
Output: origin
git remoteLihat daftar remote.
git remote
origin
git remote -vDescription: Lihat URL remote.
Example:
git remote -v
Output: origin https://github.com/...
git remote -vLihat URL remote.
git remote -v
origin https://github.com/...
git remote add <name> <url>Description: Tambah remote baru.
Example:
git remote add origin https://github.com/user/repo.git
Output: Remote origin ditambahkan
git remote add <name> <url>Tambah remote baru.
git remote add origin https://github.com/user/repo.git
Remote origin ditambahkan
git remote remove <name>Description: Hapus remote.
Example:
git remote remove origin
Output: Remote dihapus
git remote remove <name>Hapus remote.
git remote remove origin
Remote dihapus
git remote rename <old> <new>Description: Ganti nama remote.
Example:
git remote rename origin upstream
Output: Renamed
git remote rename <old> <new>Ganti nama remote.
git remote rename origin upstream
Renamed
git remote show <name>Description: Info detail remote.
Example:
git remote show origin
Output: URL, HEAD branch, tracking...
git remote show <name>Info detail remote.
git remote show origin
URL, HEAD branch, tracking...
git remote set-url <name> <url>Description: Ganti URL remote.
Example:
git remote set-url origin git@github.com:user/repo.git
Output: URL diganti ke SSH
git remote set-url <name> <url>Ganti URL remote.
git remote set-url origin git@github.com:user/repo.git
URL diganti ke SSH
PUSH-PULL-FETCH
Name
Description
Example
Output
git pushDescription: Push commit ke remote (branch saat ini).
Example:
git push
Output: Pushed to origin/main
git pushPush commit ke remote (branch saat ini).
git push
Pushed to origin/main
git push -u origin <branch>Description: Push branch baru & set upstream.
Example:
git push -u origin feature-login
Output: Branch 'feature-login' set up to track
git push -u origin <branch>Push branch baru & set upstream.
git push -u origin feature-login
Branch 'feature-login' set up to track
git push --allDescription: Push semua branch ke remote.
Example:
git push --all origin
Output: Semua branch terpush
git push --allPush semua branch ke remote.
git push --all origin
Semua branch terpush
git push --tagsDescription: Push semua tag ke remote.
Example:
git push --tags
Output: Tags terpush
git push --tagsPush semua tag ke remote.
git push --tags
Tags terpush
git push --forceDescription: Force push (timpa history remote — HATI-HATI).
Example:
git push --force
Output: ⚠️ Remote history ditimpa
git push --forceForce push (timpa history remote — HATI-HATI).
git push --force
⚠️ Remote history ditimpa
git push --force-with-leaseDescription: Force push lebih aman (cek dulu gak ada commit baru).
Example:
git push --force-with-lease
Output: Aman force push
git push --force-with-leaseForce push lebih aman (cek dulu gak ada commit baru).
git push --force-with-lease
Aman force push
git push origin --delete <branch>Description: Hapus branch di remote.
Example:
git push origin --delete feature-lama
Output: Deleted remote branch
git push origin --delete <branch>Hapus branch di remote.
git push origin --delete feature-lama
Deleted remote branch
git fetchDescription: Ambil data remote tanpa merge.
Example:
git fetch
Output: Data terdownload
git fetchAmbil data remote tanpa merge.
git fetch
Data terdownload
git fetch --pruneDescription: Fetch + hapus tracking branch yang sudah dihapus di remote.
Example:
git fetch --prune
Output: Branch remote usang dihapus
git fetch --pruneFetch + hapus tracking branch yang sudah dihapus di remote.
git fetch --prune
Branch remote usang dihapus
git pullDescription: Fetch + merge ke branch saat ini.
Example:
git pull
Output: Updated
git pullFetch + merge ke branch saat ini.
git pull
Updated
git pull --rebaseDescription: Fetch + rebase (history linear).
Example:
git pull --rebase
Output: Rebased
git pull --rebaseFetch + rebase (history linear).
git pull --rebase
Rebased
git pull --ff-onlyDescription: Pull hanya jika bisa fast-forward (aman).
Example:
git pull --ff-only
Output: Fast-forward
git pull --ff-onlyPull hanya jika bisa fast-forward (aman).
git pull --ff-only
Fast-forward
TAG
Name
Description
Example
Output
git tagDescription: Lihat daftar tag.
Example:
git tag
Output: v1.0.0
v1.1.0
git tagLihat daftar tag.
git tag
v1.0.0
v1.1.0
git tag <name>Description: Buat lightweight tag.
Example:
git tag v1.0.0
Output: Tag v1.0.0
git tag <name>Buat lightweight tag.
git tag v1.0.0
Tag v1.0.0
git tag -a <name> -m "msg"Description: Buat annotated tag (disarankan).
Example:
git tag -a v2.0.0 -m "Release v2"
Output: Annotated tag v2.0.0
git tag -a <name> -m "msg"Buat annotated tag (disarankan).
git tag -a v2.0.0 -m "Release v2"
Annotated tag v2.0.0
git tag -d <name>Description: Hapus tag lokal.
Example:
git tag -d v1.0.0
Output: Deleted tag
git tag -d <name>Hapus tag lokal.
git tag -d v1.0.0
Deleted tag
git push origin <tag>Description: Push 1 tag ke remote.
Example:
git push origin v1.0.0
Output: Tag terpush
git push origin <tag>Push 1 tag ke remote.
git push origin v1.0.0
Tag terpush
git push origin --delete <tag>Description: Hapus tag di remote.
Example:
git push origin --delete v1.0.0
Output: Remote tag deleted
git push origin --delete <tag>Hapus tag di remote.
git push origin --delete v1.0.0
Remote tag deleted
git checkout <tag>Description: Checkout ke tag (detached HEAD).
Example:
git checkout v1.0.0
Output: HEAD detached at v1.0.0
git checkout <tag>Checkout ke tag (detached HEAD).
git checkout v1.0.0
HEAD detached at v1.0.0
UNDO
Name
Description
Example
Output
git reset --soft <commit>Description: Reset HEAD ke commit, simpan perubahan di staging.
Example:
git reset --soft HEAD~1
Output: Commit terakhir di-undo, file tetap staged
git reset --soft <commit>Reset HEAD ke commit, simpan perubahan di staging.
git reset --soft HEAD~1
Commit terakhir di-undo, file tetap staged
git reset --mixed <commit>Description: Reset HEAD ke commit, simpan perubahan di working (default).
Example:
git reset HEAD~1
Output: Commit di-undo, file unstaged
git reset --mixed <commit>Reset HEAD ke commit, simpan perubahan di working (default).
git reset HEAD~1
Commit di-undo, file unstaged
git reset --hard <commit>Description: Reset HEAD & buang semua perubahan (BAHAYA).
Example:
git reset --hard HEAD~1
Output: ⚠️ Perubahan hilang permanen
git reset --hard <commit>Reset HEAD & buang semua perubahan (BAHAYA).
git reset --hard HEAD~1
⚠️ Perubahan hilang permanen
git revert <commit>Description: Buat commit baru yang membatalkan commit tertentu (AMAN).
Example:
git revert a1b2c3d
Output: Commit revert dibuat
git revert <commit>Buat commit baru yang membatalkan commit tertentu (AMAN).
git revert a1b2c3d
Commit revert dibuat
git revert --no-commit <commit>Description: Revert tanpa auto-commit.
Example:
git revert --no-commit a1b2c3d
Output: Perubahan di staging
git revert --no-commit <commit>Revert tanpa auto-commit.
git revert --no-commit a1b2c3d
Perubahan di staging
git reflogDescription: Lihat history HEAD (penyelamat commit hilang).
Example:
git reflog
Output: a1b2c3d HEAD@{0}: commit: ...
git reflogLihat history HEAD (penyelamat commit hilang).
git reflog
a1b2c3d HEAD@{0}: commit: ...
git checkout <commit> -- <file>Description: Kembalikan 1 file ke versi commit tertentu.
Example:
git checkout a1b2c3d -- index.html
Output: File kembali
git checkout <commit> -- <file>Kembalikan 1 file ke versi commit tertentu.
git checkout a1b2c3d -- index.html
File kembali
IGNORE
Name
Description
Example
Output
.gitignoreDescription: File untuk mengabaikan file/folder dari Git.
Example:
node_modules/ .env .DS_Store
Output: File diabaikan
.gitignoreFile untuk mengabaikan file/folder dari Git.
node_modules/ .env .DS_Store
File diabaikan
git rm --cached <file>Description: Hentikan tracking file (tetap ada di lokal).
Example:
git rm --cached file.log
Output: Untracked
git rm --cached <file>Hentikan tracking file (tetap ada di lokal).
git rm --cached file.log
Untracked
git rm <file>Description: Hapus file dari Git & lokal.
Example:
git rm file.log
Output: Deleted
git rm <file>Hapus file dari Git & lokal.
git rm file.log
Deleted
git rm -r <folder>Description: Hapus folder dari Git & lokal.
Example:
git rm -r old-folder
Output: Folder deleted
git rm -r <folder>Hapus folder dari Git & lokal.
git rm -r old-folder
Folder deleted
git check-ignore <file>Description: Cek apakah file diabaikan .gitignore.
Example:
git check-ignore node_modules/
Output: node_modules/
git check-ignore <file>Cek apakah file diabaikan .gitignore.
git check-ignore node_modules/
node_modules/
GITHUB-CLI
Name
Description
Example
Output
gh auth loginDescription: Login ke GitHub CLI.
Example:
gh auth login
Output: Authenticated
gh auth loginLogin ke GitHub CLI.
gh auth login
Authenticated
gh repo create <name>Description: Buat repo baru di GitHub.
Example:
gh repo create my-project --public
Output: Repo created
gh repo create <name>Buat repo baru di GitHub.
gh repo create my-project --public
Repo created
gh repo clone <user/repo>Description: Clone repo via GitHub CLI.
Example:
gh repo clone user/repo
Output: Cloned
gh repo clone <user/repo>Clone repo via GitHub CLI.
gh repo clone user/repo
Cloned
gh repo viewDescription: Buka repo di browser.
Example:
gh repo view --web
Output: Browser terbuka
gh repo viewBuka repo di browser.
gh repo view --web
Browser terbuka
gh pr createDescription: Buat Pull Request.
Example:
gh pr create --title "feat: login" --body "..."
Output: PR created
gh pr createBuat Pull Request.
gh pr create --title "feat: login" --body "..."
PR created
gh pr listDescription: Lihat daftar PR.
Example:
gh pr list
Output: #1 feat: login
gh pr listLihat daftar PR.
gh pr list
#1 feat: login
gh pr checkout <n>Description: Checkout branch dari PR.
Example:
gh pr checkout 1
Output: Switched
gh pr checkout <n>Checkout branch dari PR.
gh pr checkout 1
Switched
gh pr merge <n>Description: Merge PR.
Example:
gh pr merge 1 --squash
Output: Merged
gh pr merge <n>Merge PR.
gh pr merge 1 --squash
Merged
gh issue createDescription: Buat issue baru.
Example:
gh issue create --title "bug: ..." --body "..."
Output: Issue #1 created
gh issue createBuat issue baru.
gh issue create --title "bug: ..." --body "..."
Issue #1 created
gh issue listDescription: Lihat daftar issue.
Example:
gh issue list
Output: #1 bug: ...
gh issue listLihat daftar issue.
gh issue list
#1 bug: ...
gh release create <tag>Description: Buat release.
Example:
gh release create v1.0.0 --title "v1.0.0"
Output: Release created
gh release create <tag>Buat release.
gh release create v1.0.0 --title "v1.0.0"
Release created
gh gist create <file>Description: Buat gist dari file.
Example:
gh gist create script.js --public
Output: Gist created
gh gist create <file>Buat gist dari file.
gh gist create script.js --public
Gist created
CONVENTIONAL-COMMITS
Name
Description
Example
Output
feat:Description: Fitur baru.
Example:
feat: add login page
Output: Minor version bump
feat:Fitur baru.
feat: add login page
Minor version bump
fix:Description: Perbaikan bug.
Example:
fix: resolve navbar overlap
Output: Patch version bump
fix:Perbaikan bug.
fix: resolve navbar overlap
Patch version bump
chore:Description: Tugas rutin / maintenance.
Example:
chore: update dependencies
Output: No version bump
chore:Tugas rutin / maintenance.
chore: update dependencies
No version bump
docs:Description: Perubahan dokumentasi.
Example:
docs: update README
Output: No version bump
docs:Perubahan dokumentasi.
docs: update README
No version bump
style:Description: Formatting, spasi, dll (tanpa ubah logika).
Example:
style: fix indentation
Output: No version bump
style:Formatting, spasi, dll (tanpa ubah logika).
style: fix indentation
No version bump
refactor:Description: Refactor kode tanpa ubah fitur.
Example:
refactor: simplify auth logic
Output: No version bump
refactor:Refactor kode tanpa ubah fitur.
refactor: simplify auth logic
No version bump
perf:Description: Performa optimization.
Example:
perf: lazy load images
Output: Patch version bump
perf:Performa optimization.
perf: lazy load images
Patch version bump
test:Description: Tambah/perbaiki testing.
Example:
test: add unit test for login
Output: No version bump
test:Tambah/perbaiki testing.
test: add unit test for login
No version bump
build:Description: Perubahan build system/dependencies.
Example:
build: upgrade webpack to v5
Output: No version bump
build:Perubahan build system/dependencies.
build: upgrade webpack to v5
No version bump
ci:Description: Perubahan CI/CD.
Example:
ci: add GitHub Actions workflow
Output: No version bump
ci:Perubahan CI/CD.
ci: add GitHub Actions workflow
No version bump
revert:Description: Membatalkan commit sebelumnya.
Example:
revert: feat: add login page
Output: Patch version bump
revert:Membatalkan commit sebelumnya.
revert: feat: add login page
Patch version bump
BREAKING CHANGE:Description: Perubahan yang tidak backward-compatible.
Example:
feat!: drop support for Node 14 BREAKING CHANGE: ...
Output: Major version bump
BREAKING CHANGE:Perubahan yang tidak backward-compatible.
feat!: drop support for Node 14 BREAKING CHANGE: ...
Major version bump