Cheatsheet: Git
Basic Commands
Initialize a new Git repository
Clone an existing repository
Clone into a folder
Check repository status
Stage changes for commit
Commit changes
Branching & Merging
Create a new branch
Switch to a branch
Create and switch to a new branch
Merge a branch into the current branch
Delete a branch
Checkout a tag into a new branch
Working with Remote Repositories
Add a remote repository
Fetch changes from a remote repository
Fetch changes from a remote repository and include tags
Pull changes from a remote repository
Push changes to a remote repository
List all remote repositories
Undo & Restore
Undo local changes to a file
Unstage a file
Revert to a previous commit (soft reset)
Revert to a previous commit (hard reset, discards changes)
Remove untracked files
Stashing & Rebasing
Stash uncommitted changes
Apply stashed changes
Create a rebase onto another branch
Continue a rebase after resolving conflicts
Abort an ongoing rebase
Git Bisect
Start a binary search for the commit introducing a bug
Mark a known bad commit (where the bug is present)
Mark a known good commit (where the bug is absent)
Mark the current commit as bad
Mark the current commit as good
Run a custom script to automate bisecting
Reset the repository to its original state after bisecting
Git Switch
Create a new branch and switch to it
Switch to an existing branch
Switch to a branch based on a specific commit
Discard changes in the working directory and switch branches
Git Cherry-Pick
Apply a specific commit to the current branch
Cherry-pick a range of commits
Cherry-pick multiple non-consecutive commits
Continue cherry-pick after resolving conflicts
Abort cherry-pick operation
Applying Changes from a Different Remote
Add a new remote
Fetch changes from a remote branch
Merge changes from a remote branch into the current branch
Rebase current branch onto a remote branch
Checkout a branch from a different remote