WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Git · Intermediate · question 32 of 100

What is the purpose of ’git blame’, and how do you use it?

📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

In Git, git blame is a command that can be used to view the author and last modification time of each line in a file. This is useful for identifying who made changes to a file and when those changes were made.

Here’s how to use git blame:

Open your Git repository in your terminal.

Use the git blame command followed by the path to the file that you want to view:

    # View the git blame information for a file
    git blame <file-path>

The output of the git blame command will display the commit hash, author name, and last modification time for each line in the file. For example:

    abc1234 (John Smith 2022-03-18 13:00:00 +0800  1) This is the first line of the file
    def5678 (Jane Doe 2022-03-19 14:00:00 +0800  2) This is the second line of the file
    abc1234 (John Smith 2022-03-18 13:00:00 +0800  3) This is the third line of the file

In this example, the first and third lines of the file were last modified by John Smith on March 18, 2022, and the second line was last modified by Jane Doe on March 19, 2022.

Use the -L option followed by a range of line numbers to view the git blame information for a specific range of lines in the file. For example:

    # View the git blame information for lines 3-5 of a file
    git blame -L 3,5 <file-path>

In this command, -L 3,5 specifies that you want to view the git blame information for lines 3-5 of the file.

In summary, git blame is a command that can be used to view the author and last modification time of each line in a file. This is useful for identifying who made changes to a file and when those changes were made. You can use git blame followed by the path to the file to view the git blame information for the entire file, or you can use the -L option followed by a range of line numbers to view the git blame information for a specific range of lines in the file.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Git interview — then scores it.
📞 Practice Git — free 15 min
📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

All 100 Git questions · All topics