Viewing Commit Changes

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

Commit Details Files Changed

Accessing 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 the Google Cloud Source Repositories UI.

Using the Change History panel

To view the commit details from the Change History panel:

  1. From the My Source or All Repositories view, select a repository.

    The File view opens.

  2. Browse to the file you want to view and select it.

  3. Click the History link in the upper right corner. The Commit History panel displays a list of commits. Each row displays the hash for that commit as a hyperlink.

  4. Click the hash of the commit to open the Commit Details view.

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

And 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 cases, click the hash of the commit to open the Commit Details view.

Viewing line changes

Use the Commit Details view to see which lines were changed in each file.

To view line changes

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

  2. Locate the file you want to view.

  3. Click the Down Arrow icon located at the end of the row for that file.

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

A File with Changes Expanded

If you want to view all of the changes at the same time, click the Expand All button located on the right side of the Files Changed section. The Files Changed section expands to display all of the changes made to each file.

Diffing 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:

  1. Access the Commit Details view for a specific commit.
  2. Click the path to the file you want to view. The Diff view opens. This view contains two panels. The left panel displays the previous version of the file. The right panel displays the file as it existed at the time of the commit.

Diff View

Comparing commits

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

To compare two commits:

  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 dropdown lists.

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:

  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 dropdown 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