All resources
WorkflowBeginner1 min read

Git Workflow Cheatsheet

Branching, Conventional Commits, keeping branches current and undoing mistakes without losing work.

The feature-branch loop

bash

git switch main && git pull

git switch -c feat/palette-export

git add -p

git commit -m "feat(palettes): export tokens as CSS variables"

git push -u origin feat/palette-export

Conventional Commits

Format: type(scope): summary. A consistent prefix makes history scannable and lets tools generate changelogs and version bumps.

TypeUse forVersion bump
featA new featureMinor
fixA bug fixPatch
refactorCode change without behavior change—
docs / style / testDocs, formatting, tests—
feat! or BREAKING CHANGE:Incompatible API changeMajor

Keep your branch up to date

bash

git fetch origin

git rebase origin/main

Rebasing replays your commits on top of the latest main, giving a linear history. After rebasing an already pushed branch, push with --force-with-lease, which refuses to overwrite commits you have not seen.

Undo without panic

SituationCommand
Discard unstaged changes in a filegit restore <file>
Unstage a filegit restore --staged <file>
Fix the last commit message or add a filegit commit --amend
Undo the last commit, keep the changesgit reset --soft HEAD~1
Revert a pushed commit safelygit revert <sha>
Find a commit you “lost”git reflog