Show Menu
Cheatography

GitWorkshop1 Cheat Sheet (DRAFT) by

Git workshop deel1+2

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Basics

Twee commands achter elkaar
git comman­do1;git commando2

Setup

Je username
git config --global user.name
Zet username
git config --global user.name 'Hans Klok'
Je emailadres
git config --global user.email
Fix push -u
git config --global push.d­efault current
Zet notepad++ als editor
git config --global core.e­ditor notepad++
edit config
git config --global --edit
Fix schannel
git config --global http.s­slb­ackend schannel

Repo

Clone
git clone http://..
Maak lokale repo
git init
Toon remotes
git remote -v

Checkout

Switch naar branch
Git checkout naam
Maak nieuwe branch uit bestaande, switch niet
Git branch naam
Maak nieuwe branch uit bestaande en switch
Git checkout -b naam
Switch naar vorige branch
Git checkout -
Verwijder branch
Git branch -d naam
 

Commit

Toevoegen bestand
git add bestan­d.txt
Toevoegen alle bestanden (huidige + subfol­ders)
git add .
Commit
git commit -am message
Voor de commit message kan je enkel of dubbel quotes gebruiken. Alleen nodig indien er spaties in je message zitten.

Push

Push en maak tracking
git push -u
Push
git push
Force push "­saf­e"
git push --forc­e-w­ith­-lease
Werkt
push -u
niet? Doe dan eenmalig
git config --global push.d­efault current

Cherry pick

neem commit over
git cherry­-pick hash

Revert changes / bestand

Verwijder working copy changes
Git checkout .
Reset bestand uit andere branch
git checkout origin­/master bestan­d.txt
 

Reset - verwijder commit­s/c­hanges

reset naar commit
git reset commit
Verwijder laatste commit, behoud changes
Git reset head~1
Verwijder laatste commit, gooi weg changes
Git reset head~1 --hard
Weggooien working changes
Git reset --hard
Reset aan remote
git reset origin­/branch --hard
Let op, --hard gooit echt changes weg!

Amend / aanpassen laatste commit

Aanpassen laatste commit
git commit --amend -m message

Rebase / aanpassen commits

intera­ctive rebase op origin/dev
git rebase -i origin/dev
intera­ctive rebase op commit
git rebase -i 3502df64ca
intera­ctive rebase laatste 4 commits
git rebase -i head~4
stop rebase
git rebase --abort

Alias

Maak alias (pushf)
git config --global alias.p­ushf 'push --forc­e-w­ith­-lease'
maak alias (amend)
git config --global alias.a­mend 'commit -a --amend --no-edit'