Git Cheatsheet

Snelle referentiegids voor essentiële Git commando's. Doorzoekbare cheatsheet voor branches, commits, merges, en meer.

Team ontwikkelingsworkflow

In professionele omgevingen volgen teams meestal een branching-strategie waarbij elke taak zijn eigen branch krijgt. Dit isoleert functies en voorkomt dat onafgemaakte code de hoofdapplicatie breekt.

💡

Professionele tips: Streef altijd naar kleine, atomaire commits. Voordat u uw werk samenvoegt, gebruik 'git fetch' en dan 'git rebase origin/dev' (of main) om ervoor te zorgen dat uw code compatibel is met de nieuwste versie. Gebruik ten slotte 'git push -f' op uw feature branch om de remote bij te werken met uw gerebased geschiedenis.

Configuratie

Stel de globale configuratie in

git config --global user.name "[name]" git config --global user.email "[email]"

Configureert uw identiteit voor alle repositories op uw systeem.

Aan de slag

Maak een git repository

git init

Initialiseert een nieuw Git repository in de huidige directory.

Kloon een bestaande git repository

git clone [url]

Kopieert een bestaand Git repository van een remote server.

Commit

Commit alle getraceerde wijzigingen

git commit -am "[commit message]"

Staget en commit alle gewijzigde getraceerde bestanden in één commando.

Voeg nieuwe wijzigingen toe aan de laatste commit

git commit --amend

Werkt de laatste commit bij met huidige wijzigingen en wijzigt optioneel het bericht.

Branching

Maak een nieuwe branch

git branch [branch-name]

Maakt een nieuwe branch aan bij de huidige pointer.

Schakel over naar een branch

git checkout [branch-name]

Verplaatst HEAD naar de opgegeven branch.

Voeg een branch samen met de huidige branch

git merge [branch-name]

Combineert geschiedenis van een andere branch in uw huidige branch.

Maak en schakel over naar een branch

git checkout -b [branch-name]

De meest gebruikelijke manier om te beginnen met een nieuwe functie.

Synchronisatie

Haal updates op van remote

git fetch

Download remote wijzigingen zonder ze samen te voegen.

Haal laatste wijzigingen op

git pull

Haalt wijzigingen op en probeert ze onmiddellijk samen te voegen.

Rebase huidige branch op main

git rebase main

Speelt uw commits opnieuw af bovenop de laatste main branch.

Push wijzigingen (Force)

git push -f

Forceert update van de remote branch met uw lokale geschiedenis. Gebruik alleen op privé branches!

Handige commando's

Controleer status

git status

Zie welke bestanden gewijzigd, gestaged of niet getraceerd zijn.

Stash wijzigingen

git stash

Verbergt tijdelijk wijzigingen om aan iets anders te werken.

Bekijk geschiedenis

git log --oneline --graph --all

Visualiseert de commit geschiedenis over alle branches.

Hoe gebruik je deze Git Cheatsheet

  1. Browse the cheatsheet to find the Git command you need.
  2. Commands are organized by category: Configuration, Get Started, Commit, Branching, Syncing, and Useful Commands.
  3. Click the copy button next to any command to copy it to your clipboard.
  4. Paste the command into your terminal and modify the placeholder values as needed.

Advanced Rebasing

Rebasing is often preferred over merging to maintain a clean, linear project history. Instead of creating a 'merge commit', it repositions your commits at the end of the target branch.

Tip

Remember: Never rebase a public branch that others are working on, as it rewrites history and can cause significant conflicts for your peers.

Key Features

  • Essential Git commands organized by workflow category
  • One-click copy for every command
  • Clear descriptions explaining what each command does
  • Covers configuration, branching, syncing, and more
  • Team workflow guidance with professional tips
  • Rebasing best practices and safety warnings
  • Works offline once loaded in your browser

Common Use Cases

  • Quick reference while working in the terminal
  • Onboarding new developers to Git workflows
  • Reviewing branching and merging strategies
  • Learning Git commands for the first time
  • Refreshing memory on less frequently used commands
  • Setting up Git configuration on a new machine

Veelgestelde Vragen

What is the difference between git merge and git rebase?

Git merge creates a new merge commit that combines two branches, preserving the full history. Git rebase replays your commits on top of the target branch, creating a linear history. Rebase produces a cleaner log but should never be used on shared public branches.

When should I use git stash?

Use git stash when you need to switch branches but have uncommitted changes you are not ready to commit. Stash saves your working directory state temporarily. You can restore it later with 'git stash pop' on any branch.

Is it safe to use git push --force?

Force pushing is safe only on branches that you alone work on, such as personal feature branches. Never force push to shared branches like main or develop, as it rewrites remote history and can cause other team members to lose their work.

Gerelateerde Tools