Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

commit

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.

like image 395
Femto Trader Avatar asked Oct 18 '22 19:10

Femto Trader


1 Answers

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
like image 56
VonC Avatar answered Nov 02 '22 08:11

VonC