Git Cheatsheet
Git Cheatsheet
A comprehensive guide to Git commands and workflows.
Basic Commands
# Initialize a repository
git init
# Clone a repository
git clone <repository-url>
# Check status
git status
# Add files to staging
git add <file>
git add .
# Commit changes
git commit -m "Commit message"
# Push changes
git push origin <branch>
# Pull changes
git pull origin <branch>
Branching
# Create a new branch
git branch <branch-name>
# Switch to a branch
git checkout <branch-name>
# Create and switch to a new branch
git checkout -b <branch-name>
# List all branches
git branch -a
# Delete a branch
git branch -d <branch-name>
Advanced Commands
# Stash changes
git stash
# Apply stashed changes
git stash apply
# View commit history
git log
# Revert a commit
git revert <commit-hash>
# Reset to a specific commit
git reset --hard <commit-hash>
Tags:
git
version control