Skip to content

Instantly share code, notes, and snippets.

@edomaru
Last active August 29, 2015 14:21
Show Gist options
  • Save edomaru/b393ad253195994cee9d to your computer and use it in GitHub Desktop.
Save edomaru/b393ad253195994cee9d to your computer and use it in GitHub Desktop.
Git Commands Cheatsheet

Git Commands cheatsheet

Basic

Undoing Changes

Inisialisasi Git

$ git init

menambahkan perubahan ke dalam stage

$ git add -A

komit perubahan

$ git commit -m "Message"

menambahkan seluruh perubahan ke dalam stage, lalu kommit (one line command)

-a artinya all changes

$ git commit -am "Message"

menyimpan repositori local ke git server

$ cd /to/repository $ git remote add origin <alamat repository>

menyimpan perubahan dari local ke server git

$ git push -u origin --all

menyimpan perubahan dari brance terntentu di local ke server git

$ git push -u origin <nama-brance>

default brance

default brance adalah master

pindah brance

$ git checkout <nama-brance>

buat brance baru dan pindah ke brance yanb baru dibuat

$ git checkout -b <nama-brance

menampilkan branch yang ada

$ git branch

menggabungkan brance ke master

$ git checkout master

$ git merge <nama-brance>

undo unstagged changes:

$ git checkout -f or

$ git reset --hard HEAD

Branching

Create a new branch

git branch branch-name

List branches

git branch -a

Switch to other branch

git checkout branch-name

Create new Branch and Checkout to it in one line

git checkout -b new-branch-name

Rename branch

git branch -m old-branch new-branch

Delete local branch

git checkout master

git branch -b branch-to-delete

Delete remote branch

git push origin --delete remote-branch-name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment