Git Cheat Sheet
π§ Setup
Set your name and email
Set default branch to main
π Create or Clone Repository
Initialize new repository
Clone existing repository
π Staging and Committing
Check file status
Stage changes
Commit staged changes
Amend last commit
π Undoing Changes
Undo Last Commit (Not Pushed)
Keep changes staged
Β
Keep changes unstaged
Β
Discard commit and changes
Reset to Specific Commit
Soft reset
Β
Mixed reset (default)
Β
Hard reset
Revert a Commit (Safe for Pushed Commits)
Create a new commit that undoes an old one
π³ Branching
List branches
Β
Create new branch
Β
Switch to a branch
Β
Create and switch
Β
Delete branch
π Merging & Rebasing
Merge a branch into current
Β
Rebase current branch onto another
Β
Interactive rebase
π€ Pushing & Pulling
Push commits
Β
Push new branch and track it
Β
Pull latest changes
π Viewing History
Full commit log
Β
Condensed view
Β
Inspect specific commit
π§Ή Cleaning Up
Delete untracked files/folders
Β
Temporarily save changes
Β
Reapply stashed changes
π¦ Tags
Β
Create a new tag
Β
Push tag to remote
π Remote Repositories
View remotes
Β
Add a remote
Β
Remove a remote
No comments to display
No comments to display