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