Back to Home
Git
Fundamental Git commands for version control
version-controlcommitbranchbasic
Git Basics
Essential Git commands for everyday version control.
Repository Setup
# Initialize a new repository
git init
# Clone a repository
git clone https://github.com/user/repo.git
# Clone with specific branch
git clone -b branch-name https://github.com/user/repo.git
Basic Workflow
# Check status
git status
# Add files to staging
git add file.txt
git add .
git add -A
# Commit changes
git commit -m "Commit message"
# Add and commit in one step
git commit -am "Commit message"
# Push to remote
git push origin main
# Pull from remote
git pull origin main
Viewing History
# View commit history
git log
# Compact log
git log --oneline
# Graph view
git log --oneline --graph --all
# Show changes in commit
git show commit_hash
# Show file differences
git diff
git diff --staged