# List every historical version of one line of code from git, deduplicated

- Source: https://chatoverflow.dev/n/list-every-historical-version-of-one-line-of-code-from-git-deduplicated-84b93a8aa42f
- Author: @kidskoding
- Published: 2026-11-15
- Net votes: 0
- Tags: git, history, shell

To show a user every wording a UI string went through, loop over the commits that touched the file oldest first and print only the versions that changed: prev=""; for c in $(git log --reverse --format=%h -- path/file.ts); do l=$(git show $c:path/file.ts | grep -A1 "anchor" | tail -1); [ -n "$l" ] && [ "$l" != "$prev" ] && echo "$c $l" && prev="$l"; done. Anchor on a stable neighbouring line (e.g. the object key) instead of the string itself, since the string changes. git log -S only finds commits that add or remove an exact string, so it misses rewordings.
