This is my Git cheatsheet. I share it in case it's of any use to anyone else.Stash Commands
Stashing
Basic Stashing
git stash
git stash save "Description"
Viewing Stashes
git stash list
git stash show stash@{n}
git stash show -p stash@{n}
Applying Stashes
git stash apply
git stash apply stash@{n}
git stash pop
git stash pop stash@{n}
Managing Stashes
git stash drop stash@{n}
git stash clear
Branching from a Stash
git stash branch new-branch
Note: Replace n with the stash index number (0 is most recent).
Rebase Commands
Basic Rebasing
git rebase <base>
git rebase -i <base>
Rebase Operations
git rebase --continue
git rebase --abort
git rebase --skip
Updating a Branch
git pull --rebase origin <branch>
Rebase onto Another Branch
git rebase --onto <newbase> <oldbase> <branch>
Preserving Merges
git rebase -p <upstream>
Note: Replace <base>, <branch>, <newbase>, <oldbase>, and <upstream> with appropriate branch or commit references.
Reset Commands
Soft Reset
git reset --soft HEAD~1
git reset --soft <commit>
Mixed Reset (Default)
git reset HEAD~1
git reset <commit>
Hard Reset
git reset --hard HEAD~1
git reset --hard <commit>
git reset --hard origin/<branch>
Reset Single File
git reset <file>
git reset --hard <file>
Reset to a Clean State
git reset --hard HEAD
Undo a Reset
git reflog
git reset --hard HEAD@{n}
Note: Be cautious with --hard resets as they discard changes permanently. Always commit or stash important changes before using --hard.
Replace <commit> with a commit hash, branch name, or relative reference (e.g., HEAD~3).