This is a draft cheat sheet. It is a work in progress and is not finished yet.
Basics
Twee commands achter elkaar |
git commando1;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.default current |
Zet notepad++ als editor |
git config --global core.editor notepad++ |
edit config |
git config --global --edit |
Fix schannel |
git config --global http.sslbackend 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 bestand.txt |
Toevoegen alle bestanden (huidige + subfolders) |
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 "safe" |
git push --force-with-lease |
Werkt push -u
niet? Doe dan eenmalig
git config --global push.default 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 bestand.txt |
|
|
Reset - verwijder commits/changes
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
interactive rebase op origin/dev |
git rebase -i origin/dev |
interactive rebase op commit |
git rebase -i 3502df64ca |
interactive rebase laatste 4 commits |
git rebase -i head~4 |
stop rebase |
git rebase --abort |
Alias
Maak alias (pushf) |
git config --global alias.pushf 'push --force-with-lease' |
maak alias (amend) |
git config --global alias.amend 'commit -a --amend --no-edit' |
|