Git Cheat Sheet

0
584
views
1. Create
2. Local Changes
3. Commit History
4. Branches and Tags
5. Update and Publish
6. Merge and Rebase
7. Undo

↑ Table of Contents ↑

Create

Clone an existing repository. Clone repository yang sudah ada.
$ git clone ssh://user@domain.com/repo.git

Create a new local repository. Membuat repository lokal yang baru.
$ git init

↑ Table of Contents ↑

Local Changes

Changed files in your working directory. Perubahan pada direktori.
$ git status

Changes to tracked files. Melacak file yang berubah.
$ git diff

Add all current changes to the next commit. Menambahkan semua file yang berubah ke commit.
$ git add .

Add some changes in to the next commit. Menambahkan file yang berubah ke commit.
$ git add -p

Commit all changes in tracked files. Commit semua perubahan.
$ git commit -a

Commit previously staged changes. Commit perubahan.
$ git commit

Change the last commit. Mengubah commit terakhir.
$ git commit --amend

↑ Table of Contents ↑

Commit History

Show all commits, starting with newest. Menampilkan semua commit, dimulai dari terbaru.
$ git log

Show changes over time for a specific file. Menampilkan perubahan dari waktu tertentu
$ git log -p

Who changed what and when in. Menampilkan siapa yang melakukan dan kapan melakukan perubahan.
$ git blame

↑ Table of Contents ↑

Branches and Tags

List all existing branches. Daftar semua branch / cabang.
$ git branch -av

Switch HEAD branch. Pindah branch / cabang.
$ git branch -av

Create a new branch based on your current HEAD. Membuat branch / cabang baru.
$ git branch

Create a new tracking branch based on a remote branch.
$ git checkout --track <remote/branch>

Delete a local branch. Menghapus branch / cabang lokal.
$ git branch -d

Mark the current commit with a tag
$ git tag

↑ Table of Contents ↑

Update and Publish

List all currently configured remotes.
$ git remote -v

Show information about a remote. Menampilkan semua informasi yang di remote.
$ git remote show

Add new remote repository, ame . Menambahkan direktori remote baru.
$ git remote add

Download all changes from , but don’t integrate into HEAD. Unduh semua perubahan dari remote, tapi tidak digabung dengan HEAD.
$ git fetch

Dowonload changes and directy merge/integrate into HEAD. Unduh perubahan dan digabung.
$ git pull

Publish local changes on a remote. Mempublikasikan local ke remote.
$ git push

Delete a branch on the remote. Hapus branch di remote.
$ git branch dr <remote/branch>

Publish your tags.
$ git push --tags

↑ Table of Contents ↑

Merge and Rebase

Merge into your HEAD. Menggabungkan branch ke HEAD.
$ git merge

Rebase your current HEAD onto .
$ git rebase

Abort a rebase. Membatalkan rebase.
$ git rebase --abort

Continue a rebase after resolvng conflicts.
$ git rebase --continue

Use your confugred merge tool to solve conflicts.
$ git mergetool

Use your editor to manually solve conflicts and (after resolving) mark as resolved.
$ git add
$ git rm

↑ Table of Contents ↑

Undo

Discard all local changes in your working directory.
$ git reset --hard HEAD

Discard local changes a specific file.
$ git checkout HEAD

Revert a commit (by producing a new commit with contrar changes).
$ git revert

Reset your HEAD pointer to a previous commit and discard all changes since then.
$ git reset --hard

And preserve all changes as unstaged changes.
$ git reset

And presere uncommited local changes.
$ git reset --keep

LEAVE A REPLY

Please enter your name here
Please enter your comment!