Last updated January 21, 2016.
The git blame command can be used to determine when a certain change was made. This document will explain how to use this functionality in the terminal and in Drupal's git repository browser at drupalcode.org.
Using git blame on the command line
- Clone the repo you wish to run a blame on by following the revision instructions on the "Version Control" tab. For example, see: the Drupal revision instructions.
- In your terminal, run the command
git blame <options> <filename>, where the filename is the name of the file you wish to run the blame on, and the options allow you to specify things like line number and range. See the git blame documentation for details. For example, this command will blame lines 62 through 76 of
git blame core/lib/Drupal/Core/Entity/Entity.php -L 62,76
- In the results of your git blame, you should see a hash indicating which commit made the last change to each line. Running
git show <your hash>should give you more details of that specific commit. The commit message should also contain the Drupal.org issue ID, which you can read for background information on the commit.
Using git blame on drupalcode.org
Unfortunately, drupalcode.org no longer supports git blame via the repo browser.
Generate statistics from 'git blame' with 'git fame'
Running git fame requires Ruby version >= 1.9.2. To check your current Ruby version, execute in your terminal: