Femto Trader
Femto Trader

Reputation: 2014

Know when a line of code was added to a GitHub repository

I wonder how to know when a line of code was added to a GitHub repository.

I'm looking for commit hash so I could add a comment on this line of code (instead of opening an issue)

For example I have to know when this line

https://github.com/username/project/blob/master/path/to/file#L6

was added

So I could using https://github.com/username/project/commit/COMMIT_HASH

add a comment about this line.

Upvotes: 5

Views: 441

Answers (1)

VonC
VonC

Reputation: 1323125

Directly on GitHub, the button "blame" can give you the last commit having modified that line.
But not the first commit.

For that, you need to clone the repo and use a git log -L:

 git log --pretty=short -u -L 6,6:afile.txt

Upvotes: 3

Related Questions