Git Links

Git Links is an unbelievably simple format for permalinks in the code. Imagine a file in your repo refers to mydoc.md:32. You specified the line because files can be large. But an edit to mydoc.md can ruin your link; it becomes misleading. GitHub links, in particular, have always had that problem. Git Links adds a hashlet to the line number, e.g. mydoc.md:32:eZ. That is a prefix of the git blob hash of that particular version of the file, in Base64. Now, any program can double-check whether the file has changed and what the link pointed at.

permalinks in code comments
permalinks in code comments

The most basic implementation of Git Links can just parse git output. Some basic string matching and regexes can get you 80% there. To make things snappy in bigger repos, an implementation has to level up. Beagle Bee employs libdog and search indexes to cross-link arbitrary repos.

Either way, line-precise links become usable and useful.

FAQ

  1. So :eZ is two symbols? Is that enough of a hash prefix?
  2. Which tools support it?
  3. Would it work with jj?
  4. Can it reference a file in a different repo?
  5. LLMs will have infinite context, there is no need to point at a line.
  6. Why don't we use section numbers? That works.
  7. We can use small Markdown files for everything, no need to mention the line.
  8. Obsidian/OKF/Markdown-base solves that somehow.
  9. Should I write these two symbols each time?