Git Cheatsheet

Quick reference for common Git commands.

Setup & Init

  • Initialize repository
    git init
  • Clone repository
    git clone <url>
  • Set user name
    git config --global user.name "name"

Stage & Snapshot

  • Stage all files
    git add .
  • Commit changes
    git commit -m "msg"
  • Status
    git status

Branch & Merge

  • List branches
    git branch
  • Create & switch branch
    git checkout -b <branch>
  • Merge branch
    git merge <branch>

Share & Update

  • Push commits
    git push origin <branch>
  • Pull changes
    git pull
  • Fetch origin
    git fetch