Setup & Configuration

bash
# Configure user information
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

# View configuration
git config --list

Creating & Cloning

bash
# Initialize new repository
git init

# Clone existing repository
git clone https://github.com/username/repo.git

Basic Workflow

bash
# Check status
git status

# Stage files
git add filename.txt
git add .

# Commit changes
git commit -m "Your message"

# Push to remote
git push origin main

Branching

bash
# List branches
git branch

# Create branch
git branch feature-name

# Switch branch
git checkout feature-name

# Create and switch (shortcut)
git checkout -b feature-name

# Delete branch
git branch -d feature-name

Remote Repositories

bash
# View remotes
git remote -v

# Add remote
git remote add origin https://github.com/username/repo.git

# Pull changes
git pull origin main

# Push changes
git push origin main

History & Logs

bash
# View commit history
git log

# Compact log
git log --oneline

# Visual graph view
git log --graph --oneline --all