80%
DefinitionGit is a distributed version control system.
FlowFlowWorking tree→git add → Staging area→git commit → Local repo→git push → Remote (GitHub)
History: keeps the true history + a merge commit · rewrites commits on top of the target → linear
Safe on shared branches?: yes · no — never rebase commits others have pulled
Conflicts: resolved once · possibly per commit
Squash merge: the whole PR becomes one commit on main (clean history).
Resolve conflicts: edit the marked files,
git add, then git merge --continue / git rebase --continue.Golden rule: rebase your own local work; merge shared branches.
Discard changes to a file: git restore file
Unstage a file: git restore --staged file
Fix the last commit message / add a file: git commit --amend (only if not pushed)
Undo a pushed commit safely: git revert <sha> (new commit that reverses it)
Common mistake
git push --force on a shared branch overwrites teammates' work.Create a short-lived feature branch from
main.Commit small, focused changes with clear messages (Conventional Commits:
feat:, fix:, chore:).Open a pull request; CI runs lint, tests and build.
Review, address comments, keep the branch updated.
Protect
main: required reviews and passing checks..gitignore build output, node_modules, .env.Tags (
v1.4.0) mark releases; semantic versioning.