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