git annotate

Debugging

Annotate file lines with commit information (older blame format)


The 'git annotate' command does the same job as git blame — it labels every line of a file with the commit that last changed it — but prints the older tab-separated format that some tools still read. For everyday use, git blame is the command to learn.

Synopsis

git annotate [<options>] [<rev>] <file>
[ ] optional| or<arg> placeholder... repeatable--flag option

Examples

Annotate a file

git annotate app.js

Commit, author, date and line number for every line.

Workflow Examples

1
git annotate app.js > app.annotate

Save the output for the tool

Troubleshooting

fatal: no such path 'x' in HEAD

Cause: The file is not tracked

Check the path with git ls-files

Tips & Pitfalls

Best Practices

  • ✓Use git blame in new scripts and day-to-day work.

Common Mistakes

  • ✗Learning annotate instead of blame: blame has more options and a clearer format.

FAQ

A:

No, it is kept for compatibility, but git blame is the documented, richer command.