Forrest logo
back to the git tool

git-blame:tldr:04a44

git-blame: Print file with author name and commit hash on each line before a specific commit.
$ git blame ${commit}~ ${filename}
try on your machine

The command git blame ${commit}~ ${filename} is used to view the commit and author information for each line of a specific file in a Git repository.

Here's how the command breaks down:

  • git blame: This command is used to show commit and author information for every line in a file.
  • ${commit}~: This specifies the commit hash you want to blame. ${commit}~ means to blame the commit before the specified commit, so it refers to the previous commit before ${commit}.
  • ${filename}: This is the name of the file you want to blame.

By executing this command, you will get the commit hash, author, and the date of the previous commit (${commit}~) for each line of ${filename}. The command is particularly useful for identifying who last modified a specific line of code, or investigating the history of changes to a file.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool