Skip to content

Instantly share code, notes, and snippets.

@imerr
Last active August 13, 2026 15:22
Show Gist options
  • Select an option

  • Save imerr/3294a64eb032ed13caebfeac9692f618 to your computer and use it in GitHub Desktop.

Select an option

Save imerr/3294a64eb032ed13caebfeac9692f618 to your computer and use it in GitHub Desktop.
git-todo

git-todo

Find newly added TODO comments in staged and unstaged Git changes and print them as:

relative/path/to/file:line

By default, changes are compared against HEAD. You can optionally pass another Git revision or branch.

Usage

git todo

Compare against HEAD:

git todo

Compare against another revision:

git todo master
git todo main
git todo origin/main
git todo HEAD~3

For example:

git todo master

finds TODOs added in your current working tree compared with master.

Git alias

Add this to ~/.gitconfig:

[alias]
    todo = "!f() { ref=\"${1:-HEAD}\"; git diff \"$ref\" --unified=0 | awk 'BEGIN{IGNORECASE=1} /^\\+\\+\\+ b\\//{f=substr($0,7)} /^@@/{match($0,/\\+[0-9]+/); n=substr($0,RSTART+1,RLENGTH-1)-1; next} /^\\+/{n++; if ($0 ~ /(\\/\\/|#)[[:space:]]*todo/) print f \":\" n}'; }; f"

Then run:

git todo

or:

git todo master

Matches

The search is case-insensitive and recognises both // and # comments:

// TODO
//TODO
// todo
# TODO
#todo

Example output

Assets/Scripts/Entity/Player.cs:171
Assets/Scripts/Settings/GlobalSettings.cs:745
scripts/build.sh:32

Notes

  • git todo compares against HEAD.
  • git todo <revision> compares against the specified revision.
  • Includes both staged and unstaged tracked changes.
  • Does not include untracked files.
  • Reports only added lines from the diff.
  • Output uses repository-relative paths with line numbers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment