Modern QA2026Practical Git Commands for QA Engineers — tiles
Log inJoin
53 / 57 · 17 Git & Version Control · Gitignore and Practical Tips← prev⊞ allnext →☰ Read as one page

7.5Practical Git Commands for QA Engineers

Investigating Changes

# See what changed in the last 5 commits (useful for targeted testing)
git log --oneline -5 --stat

# Find all commits that touched a specific test file
git log --follow -- tests/checkout.spec.ts

# See who last modified each line of a test file (find the right person to ask)
git blame tests/checkout.spec.ts

# See the diff between your branch and main (what the PR will show)
git diff main...HEAD

# Show only the names of changed files (great for deciding what to test)
git diff main...HEAD --name-only

# Show changes in a specific file since a specific commit
git diff v2.3.0..HEAD -- tests/checkout.spec.ts

Managing Work in Progress

# Stash your work-in-progress to switch branches for a hotfix
git stash push -m "WIP: refactoring payment tests"

# List all stashes
git stash list

# Apply the most recent stash (keeps it in the stash list)
git stash apply

# Pop the most recent stash (removes it from the stash list)
git stash pop

# Apply a specific stash
git stash apply stash@{2}

# Switch to a different branch, do work, and come back
git stash push -m "WIP: payment tests"
git checkout hotfix/urgent-fix
# ... do the work ...
git checkout feature/my-branch
git stash pop

Undoing Mistakes

# Undo the last commit but keep the changes staged
git reset --soft HEAD~1

# Undo the last commit and unstage the changes
git reset HEAD~1

# Discard all uncommitted changes in a specific file
git checkout -- tests/broken-test.spec.ts

# Revert a specific commit (creates a new commit that undoes the changes)
git revert abc123f

# Recover a deleted branch (find the commit hash in reflog)
git reflog
# Find the commit hash of the branch tip
git checkout -b recovered-branch abc123f

Searching History

# Find commits that contain a specific string in the diff
git log -S "data-testid=\"checkout-button\"" --oneline

# Find commits with a message matching a pattern
git log --grep="fix.*flaky" --oneline -i

# Find when a line was added or removed
git log -p -S "waitForTimeout" -- tests/

# Show the commit that last modified a specific line
git log -1 -L 42,42:tests/checkout.spec.ts