Asosiy/Cheat Sheets/Essential Git Commands Cheat Sheet
devops

Essential Git Commands Cheat Sheet

A comprehensive reference of production Git commands designed to eliminate merge headaches and maintain pristine commit history.

Branching & Switching

git switch -c feature/login

Create and switch to a new branch (modern alternative to checkout -b)

git branch -d branch-name

Safely delete a merged branch

git branch -a

List all local and remote branches

Stash & Undoing Changes

git stash push -m 'wip-work'

Shelve uncommitted local changes into stash stack

git stash pop

Restore and pop latest stashed changes back into working tree

git restore --staged <file>

Remove a file from staging without altering file contents

git commit --amend --no-edit

Add recent edits to the previous commit without changing the commit message

Interactive Rebase & Hygiene

git rebase -i HEAD~3

Interactively squash, edit, or reword the last 3 commits

git reflog

Chronological log of HEAD movements to rescue lost or deleted commits

Amaliy Maslahatlar va Xavfsizlik
Never run `git push --force` directly against shared production branches
Adhere to atomic commits for easier revert and review workflows
Follow Conventional Commits specification (feat:, fix:, chore:)

Boshqa Cheat Sheetlar