Sudah lama pake Git. Pabrik pake GitHub, namun aplikasi desktop-nya memang kurang mumpuni. Seperti kata master Sigit bilang, "real developers use git command line interface". Supaya tidak lupa, mungkin ini beberapa perintah yang sering saya pakai.
[alias]
log-color = log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"
logk = log --graph --pretty=oneline --color --abbrev-commit --decorate
cpick = cherry-pick
co = checkout
ci = commit
st = status
search = log -g -i --grep
Clone specific branch
$ git clone --single-branch -b branch_name https://github.com/prabowomurti/repo.git .
Mencari stash yang hilang (bug di desktop app Github lama kalau ganti branch)
$ git log --all --graph --decorate --oneline
Cari ref seperti ini :
95c09ff (refs/stash) On unicorn_theme: GitHub: stashing before switching to master
Cari ref seperti ini :
95c09ff (refs/stash) On unicorn_theme: GitHub: stashing before switching to master
Lalu checkout sesuai sha id.
Tagging yang benar
Tagging yang salah : $ git tag v.0.1
Yang benar :
$ git tag -a v.0.1 abcdef -m "Even if version 1 svcks, ship it anyway"
Stashing
$ git stash
Untuk mengembalikan :
$ git stash pop #stash terakhir
Cherry-picking
Mengambil commit dari branch lain ke branch master (hilangkan parameter -n bila hendak langsung dicommit).
$ git cpick -n abcdef
Untuk commit abcde0 hingga abcdef
$ git cpick abcdef0..abcdef
Ignore tracked files or folder
Kalau sudah terlanjur ditrack, harus dihilangkan pakai
$ git rm --cache /path/to/file
Restore deleted file
$ git checkout HEAD^ /path/to/file
File renaming issue
Nggak bisa pake begini di git :
$ mv foo.txt Foo.txt
Solusi :
$ git mv -f foo.txt Foo.txt
atau set ignorecase = false di config
Discard changes (tracked files)
$ git stash save
$ git stash drop #kalau mau
Discard changes (untracked files)
$ git clean -fd
Untuk dry-run, pake parameter -n
$ git clean -fdn
Untuk interaktif
$ git clean -i
Edit last commit message
$ git commit --amend
Interactive mode when do the commit
$ git add --interactive
Undo last commit
$ git reset --soft HEAD~1
Diff between index, head, and working tree
$ git diff // differences between index and working tree
$ git diff HEAD // differences between HEAD and working tree
$ git diff --cached // differences between index and HEAD, or all changes to be committed
Diff between index, head, and working tree
$ git diff // differences between index and working tree
$ git diff HEAD // differences between HEAD and working tree
$ git diff --cached // differences between index and HEAD, or all changes to be committed
Hm, apa lagi ya?
Tidak ada komentar:
Posting Komentar
speak now or forever hold your peace