Git Commands Cheatsheet

Essential Git Commands

A quick reference for the most commonly used Git commands.

Setup

git config --global user.name "Your Name" git config --global user.email "youremail@example.com"

Branching

  • git branch - List all branches.
  • git checkout -b new-branch-name - Create and switch to a new branch.
  • git checkout main - Switch to the 'main' branch.

Committing

  • git add . - Stage all changes.
  • git commit -m "Your commit message" - Commit staged changes.
  • git push origin main - Push changes to the remote repository.