A mass reformat commit (Prettier, Black) ruined `git blame`. How do you recover useful blame?
IntermediateScenarioBranching and Merging Workflows
Answer
Situation read → Blame now attributes every line to the formatting commit.
What I'd do →
- Put the formatting commit SHA in
.git-blame-ignore-revsat the repo root. - Tell local Git to use it:
git config blame.ignoreRevsFile .git-blame-ignore-revs. - GitHub's blame view reads that file automatically, no setup needed.
- Ad hoc:
git blame --ignore-rev <sha> file.py.
Why → Blame skips the listed commits and attributes lines to the previous meaningful change.
Interview tip → Do formatting changes as one isolated commit so the ignore list stays short.
More on Branching and Merging Workflows
You run `git pull` and Git stops with a merge conflict in `app.py`. What do you do?BeginnerYour feature branch is three weeks old and `main` has moved a lot. Merge `main` in, or rebase onto it?IntermediateThe team argues about fast-forward merges versus merge commits on `main`. How do you settle it?BeginnerA teammate branched from the wrong base, and their PR shows 40 unrelated commits. How do you fix it?IntermediateBefore merging, you want to see exactly what the feature branch adds compared to `main`. Which commands?BeginnerHalfway through a merge you realise you pulled the wrong branch. How do you back out?Beginner