Skip to content

Git: Debug & troubleshoot

Git commands for debug & troubleshoot (tags: #debug #performance).

Index
4 items

Git: Show compact history graph

Safe

Last 30 commits as a branch graph with tags and branch names.

git log --oneline --graph --decorate -n 30
What each part does
  1. git logcommit history
  2. --onelineone line per commit
  3. --graphdraw branch and merge lines
  4. --decorateshow branch and tag names next to commits
  5. -n 30last 30 commits

Also known as: git lg · history graph

Git: Find who last changed a line

Safe

Author, commit and date for each line in a range.

git blame -L <start>,<end> <file>
What each part does
  1. git blameshow the commit, author and date of the last change to each line
  2. -L <start>,<end>only this line range
  3. <file>the file to annotate

Also known as: blame · who changed this

Git: Search history for when a string was added

Safe

Pickaxe search: commits that added or removed the string.

git log -S "<text>" --oneline
What each part does
  1. git logshow commit history
  2. -S "<text>"pickaxe: only commits that changed how many times the text appears (added or removed it)
  3. --onelineshort SHA + subject per commit

Also known as: pickaxe · git log -S · find commit that removed

Git: Recover a lost commit with reflog

Safe

Every HEAD move, including resets and rebases. Find the SHA, then git branch rescue <sha>.

git reflog -n 20
What each part does
  1. git refloglocal history of where HEAD pointed: commits, resets, checkouts, rebases
  2. -n 20only the last 20 entries; then git checkout -b rescue <sha>

Also known as: reflog · lost commit · undo reset --hard

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…