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
๐ Remote Repositories
-
View remotes
-
Add a remote
-
Remove a remote