vincent15000's avatar

GIT : how to see who has changed what in a specific file ?

Hello,

Does someone know how to see who has changed what in a specific file ?

I already used a command to do that, but I don't remember it and I don't find it on the web.

Thanks for your help.

Vincent

0 likes
6 replies
LaryAI's avatar
Level 58

To see who has changed what in a specific file, you can use the git blame command followed by the file name. This will show you the commit hash, author, and date for each line in the file, as well as the content of the line and the commit message.

Example:

git blame myfile.txt

This will output something like:

^3d6a1b2 (John Doe 2021-01-01 10:00:00 -0500 1) This is the first line
^3d6a1b2 (John Doe 2021-01-01 10:00:00 -0500 2) This is the second line
^7b3c4d5 (Jane Smith 2021-01-02 11:00:00 -0500 3) This is the third line
^7b3c4d5 (Jane Smith 2021-01-02 11:00:00 -0500 4) This is the fourth line

In this example, John Doe made the first two changes to the file in commit 3d6a1b2, and Jane Smith made the next two changes in commit 7b3c4d5.

1 like
lukedowning19's avatar
Level 24

Further to Larry the AI's answer, if you're using PHPStorm, you can right-click in a file and enable "Git > Annotate with Git blame". This will show you who last touched each line in that file without having to leave your IDE.

1 like
click's avatar

fyi, if you type the title of your ticket into google you will get the answer immediately

1 like

Please or to participate in this conversation.