4

When a line of code is submitted to a git repository, its line number may change in future commits, by code being added or removed above it, while fundamentally still being the same line.

Given a permalink for a code-snippet, is there an API that answers the question: Do these lines of code exist in git-revision #12345abc, and if so, what are their line-numbers there (and file-name, because I suppose files can be renamed)?

It feels like this is related to git blame, but not exactly.

mhelvens
  • 4,225
  • 4
  • 31
  • 55
  • Are you looking for [`git log -L`](https://stackoverflow.com/questions/8435343/retrieve-the-commit-log-for-a-specific-line-in-a-file), or are you looking for a GitHub equivalent? The closest GitHub equivalent I'm aware of is the [file history view](https://stackoverflow.com/questions/2952507/can-github-show-the-history-of-changes-made-to-one-file-in-patch-form) (which is more like `git log -p`) – JDB Nov 15 '17 at 16:43
  • Also trying to figure out the best way to accomplish this. – skainswo Feb 16 '20 at 01:03

0 Answers0