Are you a developer, student, or open-source contributor looking to streamline your Git workflow? This comprehensive Git command cheat sheet covers over 50 essential commands, organized by category, to help you work faster and more efficiently with Git and GitHub.
Git Setup & Configuration
git config --global user.name "Your Name"– Set your usernamegit config --global user.email "email@example.com"– Set your emailgit config --list– View configuration
Daily Git Workflow
git init– Initialize a new repositorygit clone <url>– Clone a repository from remotegit status– Check file statusgit add <file>– Stage changesgit commit -m "message"– Commit staged changes
Branching & Merging
git branch– List branchesgit checkout -b <branch>– Create and switch to a new branchgit merge <branch>– Merge a branch into current
Remote Repository Commands
git remote add origin <url>– Add remotegit push -u origin <branch>– Push to remotegit pull– Fetch and merge from remote
Git Stash
git stash– Save temporary changesgit stash pop– Apply and drop latest stash
Undo Changes
git reset --hard HEAD~1– Discard last commitgit restore <file>– Discard unstaged changesgit revert <commit>– Revert a commit
Git History & Logs
git log --oneline– Simplified commit historygit diff– View unstaged changes
Git Tags
git tag <tagname>– Create a taggit push origin <tagname>– Push tag to remote
Cleanup & Aliases
git clean -fd– Remove untracked filesgit config --global alias.st status– Create alias for status
🎯 Whether you're preparing for an interview or working on daily development, this cheat sheet is your go-to reference. Save it, share it, and level up your version control skills!