Quick reference for the most commonly used Git commands, organized by category
Fundamental Git operations every developer should know
git initInitialize a new Git repository
git clone <url>Clone a repository from a remote URL
git add <file>Add files to staging area
git add .Add all files to staging area
git commit -m "message"Commit staged changes with a message
git statusShow the working tree status
git logShow commit history
Create, switch, and manage Git branches effectively
git branchList all branches
git branch <name>Create a new branch
git checkout <branch>Switch to a branch
git checkout -b <branch>Create and switch to a new branch
git merge <branch>Merge a branch into current branch
git branch -d <branch>Delete a branch
Reapply commits on top of different bases for cleaner history
git rebase <branch>Reapply commits on top of another branch
git rebase -i HEAD~3Interactive rebase of last 3 commits
git rebase --onto <new-base> <old-base>Rebase onto a different base commit
git rebase --continueContinue rebase after resolving conflicts
git rebase --abortAbort rebase and return to original state
git rebase --skipSkip current commit during rebase
Collaborate with remote repositories and teams
git remote add origin <url>Add a remote repository
git push origin <branch>Push changes to remote branch
git pull origin <branch>Pull changes from remote branch
git fetchFetch changes from remote without merging
git push -u origin <branch>Push and set upstream branch
Safely undo and recover from mistakes
git reset HEAD <file>Unstage a file
git reset --hard HEADReset to last commit (destructive)
git revert <commit>Create a new commit that undoes changes
git checkout -- <file>Discard changes in working directory
git stashTemporarily save changes
git stash popApply stashed changes
Dive deeper into Git concepts and workflows with our comprehensive guides
Learn the core concepts behind Git version control, from snapshots and commits to branching and merging.