80%
Git & GitHub Commits, branches, merge vs rebase, undoing, team workflow0/27 questions known
1. How Git thinks
DefinitionGit is a distributed version control system.
FlowFlowWorking tree→git add → Staging area→git commit → Local repo→git push → Remote (GitHub)
2. Merge vs rebase
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.
3. Undoing things
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 mistakegit push --force on a shared branch overwrites teammates' work.
4. Team workflow on GitHub
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.
Most asked (9)
QWhat is the difference between Git and GitHub?Git is a distributed version control system: a command-line tool that tracks changes to files.
QExplain the working tree, staging area and repository.A file moves through three places:
Qgit fetch vs git pull?git fetch downloads new commits and branches from the remote and updates your remote-tracking branches (origin/main).
QWhat is the difference between merge and rebase? When do you use each?Both integrate changes from one branch into another.
QWhat is a merge conflict and how do you resolve it?A conflict happens when two branches change the same lines of the same file (or one edits a file the other deletes), so Git cannot decide…
QExplain git reset (soft, mixed, hard), git revert and git restore.git reset <commit> moves the current branch pointer back: - --soft: keeps the changes staged - --mixed (default): keeps the changes in the…
QHow do you undo the last commit?It depends on whether it has been pushed and what you want to keep.
QWhat is git stash and when would you use it?git stash saves your uncommitted changes (staged and unstaged) on a stack and returns you to a clean working tree, without making a commit.
QWalk me through a pull request workflow and good code review practice.A typical flow: - update main, create a branch: feature/123-login - small, focused commits with clear messages - push and open a pull…