Viewing commit changes

You might want to see the specific changes that someone made to the files in a commit. In Cloud Source Repositories, you can views these changes by using the Files Changed section of the Commit Details view.

Commit Details Files Changed

Access the Commit Details view

You can access the Commit Details view in the following ways:

  • From the Change History panel
  • From the Commit link

Both options are available when you open a file or folder in Cloud Source Repositories.

Use the Change History panel

  1. In the Google Cloud Console, open Cloud Source Repositories.

    Open Cloud Source Repositories

    The All repositories page opens. Alternatively, you can open the My source view.

  2. Click a repository.

    The Repository Root page opens.

  3. In the Files list, browse to the file you want to view, and then click it.

  4. In the adjacent pane, click Change history.

    In the pane that is displayed, each row shows the hash ID for that commit formatted as a hyperlink.

  5. Click the hash ID link.

    The Commit Details view opens.

You can also open the Commit Details view by clicking the Commit link.

If you're viewing the latest version of the file for that branch, the Commit Information link displays the name of the branch, along with the hash of latest commit.

Commit Information Link Latest

If you're looking at a previous version of a file or folder, the Commit Information link displays the hash of the commit.

Commit Information Link Latest

If you're looking at a particular tag, the Commit Information link displays the hash associated with the tag.

Commit Information Link Latest

In all of these cases, click the hash of the commit to open the Commit Details view.

View line changes

You can use the Commit Details view to see which lines were changed in each file. To view which lines changed in a file, follow these steps.

  1. Access the Commit Details view for a specific commit.

  2. Locate the file you want to view, and then click the down arrow expand_more to expand that row.

    The Files Changed section expands to display the changes made in that file.

    A File with Changes Expanded

If you want to simultaneously view all changes to a file, click Expand All in the Files Changed section.

Diff a file

To learn more about the changes to a specific file, open the Diff view. This view provides a diff of the file against the previous commit. You can also select other commits to compare the file against.

To diff a file, follow these steps:

  1. Access the Commit Details view for a specific commit.

  2. Click the path link for the file you want to view.

    The Diff view opens. This view contains two panels. One panel displays the previous version of the file. The other panel displays the file as it existed at the time of the commit.

    Diff View

Compare commits

Another way to learn about how your code has changed over time is to compare one commit to another.

To compare two commits, follow these steps:

  1. Access the Commit Details view for a specific commit.

  2. Click Compare.

    The Compare screen opens. This screen allows you to select two different commits. By default, this screen compares the commit you selected when you opened the Commit Details screen to its immediate parent.

    You can select different commits using the Commit and To Parent drop-down lists on the Breadcrumb.

Viewing the details of a specific commit can tell you a lot about what files were changed and why. You can get an even better understanding of your code's history by viewing the parent commit. A parent commit is a commit on which the current commit is based.

To access the parent commit, follow these steps:

  1. Access the Commit Details view for a specific commit.

  2. Click the link next to the Parent.

Often, a given commit has only a single parent. But there are times when a commit has multiple parents. This happens when a commit is the result of a merge of two or more branches. If a commit has multiple parents, the Commit Details view provides a drop-down list that you can use to diff against, and navigate to, a specific parent.

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Source Repositories Documentation