debian-mirror-gitlab/doc/user/project/repository/git_blame.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
2.4 KiB
Markdown
Raw Normal View History

2020-01-01 13:55:28 +05:30
---
2020-10-24 23:57:45 +05:30
stage: Create
group: Source Code
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-01-01 13:55:28 +05:30
type: reference, howto
description: "Documentation on Git file blame."
---
2021-03-11 19:13:27 +05:30
# Git file blame **(FREE)**
2020-01-01 13:55:28 +05:30
[Git blame](https://git-scm.com/docs/git-blame) provides more information
about every line in a file, including the last modified time, author, and
2021-04-29 21:17:54 +05:30
commit hash. To view it for a file:
2020-01-01 13:55:28 +05:30
2021-04-29 21:17:54 +05:30
1. Go to your project's **Repository > Files**.
1. Select the file you want to review.
2023-05-27 22:25:52 +05:30
1. In the upper-right corner, select **Blame**.
2020-01-01 13:55:28 +05:30
2021-04-29 21:17:54 +05:30
When you select **Blame**, this information is displayed:
2020-01-01 13:55:28 +05:30
![Git blame output](img/file_blame_output_v12_6.png "Blame button output")
2021-04-17 20:07:23 +05:30
If you hover over a commit in the UI, the commit's precise date and time
are shown.
2020-01-01 13:55:28 +05:30
2020-03-13 15:44:24 +05:30
## Blame previous commit
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/19299) in GitLab 12.7.
2020-03-13 15:44:24 +05:30
2022-07-23 23:45:48 +05:30
To see earlier revisions of a specific line, select **View blame prior to this change**
2020-03-13 15:44:24 +05:30
until you've found the changes you're interested in viewing:
![Blame previous commit](img/file_blame_previous_commit_v12_7.png "Blame previous commit")
2020-01-01 13:55:28 +05:30
## Associated `git` command
If you're running `git` from the command line, the equivalent command is
`git blame <filename>`. For example, if you want to find `blame` information
about a `README.md` file in the local directory, run the following command:
2020-03-13 15:44:24 +05:30
```shell
2020-01-01 13:55:28 +05:30
git blame README.md
```
2021-04-17 20:07:23 +05:30
The output looks similar to the following, which includes the commit time
2020-01-01 13:55:28 +05:30
in UTC format:
2020-03-13 15:44:24 +05:30
```shell
2020-01-01 13:55:28 +05:30
62e2353a (Achilleas Pipinellis 2019-07-11 14:52:18 +0300 1) [![build status](https://gitlab.com/gitlab-org/gitlab-docs/badges/master/build.svg)](https://gitlab.com/gitlab-com/gitlab-docs/commits/master)
fb0fc7d6 (Achilleas Pipinellis 2016-11-07 22:21:22 +0100 2)
^764ca75 (Connor Shea 2016-10-05 23:40:24 -0600 3) # GitLab Documentation
^764ca75 (Connor Shea 2016-10-05 23:40:24 -0600 4)
0e62ed6d (Mike Jang 2019-11-26 21:44:53 +0000 5) This project hosts the repository used to generate the GitLab
0e62ed6d (Mike Jang 2019-11-26 21:44:53 +0000 6) documentation website and deployed to https://docs.gitlab.com. It uses the
```
## File blame through the API
You can also get this information over the [Git file blame REST API](../../../api/repository_files.md#get-file-blame-from-repository).