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 --stagedUndo table
| Need | Command |
|---|---|
| Discard file edits | git restore f |
| Unstage | git restore --staged f |
| Edit last local commit | git commit --amend |
| Undo local commits | git reset --soft/--mixed/--hard HEAD~n |
| Undo pushed commit | git revert sha |
| Find lost work | git 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.