Essential Git commands include: clone (copy repo), add/commit (save changes), push/pull (sync with remote), branch/checkout (manage branches), merge (combine branches), and status/log (view state). Understanding these enables effective collaboration.
Basic Workflow:
Key Concepts:
Essential Commands:
# Setup
git clone <url> # Copy repository
git init # Create new repo
git config --global user.name "Name"
git config --global user.email "email@example.com"
# Basic workflow
git status # See changes
git add . # Stage all changes
git add file.js # Stage specific file
git commit -m "message" # Commit changes
git push # Push to remote
git pull # Get latest changes
# Branches
git branch # List branches
git branch feature # Create branch
git checkout feature # Switch branch
git checkout -b feature # Create and switch
git merge feature # Merge branch
git branch -d feature # Delete branch
# Viewing history
git log # Commit history
git log --oneline # Compact history
git diff # Unstaged changes
git diff --staged # Staged changes