Roadmap › 3. Cloud & DevOps › Step 34
Git

Git & GitHub — Version Control from Basics to Advanced

How Git stores history, the daily commands, branching and merging, rebase, resolving conflicts, remotes and pull requests, branching strategies (GitFlow, trunk-based), undoing mistakes, tags and releases, hooks and the Git questions asked in every developer interview.
Quick revision for interview day. Print it or save it as a PDF.

Daily commands

bash
git status | git add -p | git commit -m "msg" | git push
git switch -c feature/x | git switch main | git pull --rebase
git log --oneline --graph --all | git diff --staged

Undo table

NeedCommand
Discard file editsgit restore f
Unstagegit restore --staged f
Edit last local commitgit commit --amend
Undo local commitsgit reset --soft/--mixed/--hard HEAD~n
Undo pushed commitgit revert sha
Find lost workgit reflog

Merge vs rebase

Merge = true history, safe for shared branches. Rebase = linear history, rewrites ids — only on your own branches. Squash merge = one commit per PR on main.

Branching strategies

GitFlow (develop/release/hotfix, versioned releases) · GitHub Flow (main + short branches) · Trunk-based (daily merges + feature flags).

Safety rules

Never commit secrets (rotate if you do) · --force-with-lease, never --force on shared branches · protect main with PR + CI policies · small PRs, frequent syncs · tag every release.