How to Search for Commits in Bitbucket Data Center

June 25, 2024
#How To#Bitbucket#Reporting#Analytics
15 min

Have you ever wasted time scrolling the mouse wheel trying to find some of the old commits? Luckily, there are some ways to make your life easier when you search for commits in Bitbucket. In this article, you will learn how to find:

  • all the commits made by a user over the last year (filter by author)
  • all the commits made to a project or a repository (filter by project/repo)
  • the commits of a user or a team made to a repository or project (filter by author/team and project/repo)
  • commits that were made long ago to a repository with high activity (filter by time).

We’ll also show you how to automate the process using the Bitbucket REST API, as well as the Awesome Graphs REST API and the Export to CSV feature.

Sourcetree search opportunities

Sourcetree is an Atlassian desktop client for working with Git and Mercurial repositories. It provides an opportunity to search for commits by an author, a commit message, and a file.

search for commits by an author, a commit message, and a file in Sourcetree

Its user-friendly interface helps find commits easier, but it’s impossible to look at them for all repositories at once as you need to go to each repo manually. Besides, it needs to be installed on each computer separately and is not available for Linux.

Use Awesome Graphs to search commits in Bitbucket

Awesome Graphs for Bitbucket is an app that helps engineering leaders and software teams find bottlenecks, improve processes, and deliver products faster by transforming invisible development activities into easy-to-understand insights and reports. It also allows exporting commit and pull requests data into a CSV file or via REST API to automate your workflow and build custom reports. Convenient search for commits isn’t its primary purpose, but a nice bonus.

This app indexes information about commits, which makes searching by author, time, or repository faster and does not affect even huge Bitbucket instances (70,000+ repositories).

Find all the commits made by a contributor

The Contributions graph shows the activity of each developer during a year as a calendar. So it’s an easy way to find all the commits made by a person to all projects and repositories. Here you can also filter the commits of a particular user by time period (up to a year) and by project or repository.

Find all the commits made by a contributor

Below the calendar, there is a list of all commits and pull requests made during the selected time span. By default, it’s a year, but it’s possible to choose any period to display.

Find all the commits made by a user

Find commits of a certain repository or project

In order to find the commits made to a specific repository or project, you can use the Activity graph. By default, it shows all commits for the last month in the Activity section below the charts. However, you can apply filters to adjust the results and see commits made by a particular team or users for a shorter or longer period. Apart from that, at the repository level, you can select specific branches. At the project level, you can choose multiple repositories to view commits made across them simultaneously.

Find commits of a certain repository or project

Search commits made long ago

And if you need to find commits made long ago, the Top Committers Report can be a good solution. In general, it is used to track developers’ contributions to the project or repository over time and find the most active ones. But here, you can also configure the Period of time and filter commits by specific Authors or Teams.

Search commits made long ago to a project or repository

As a result, it shows the list of all commits for the selected time span in the Activity section below as well as their distribution in time.

How to Search for Commits in Bitbucket Data Center

Export commit data to CSV

Awesome Graphs for Bitbucket also gives you the capability to export commit data to CSV in different ways. As a result, you’ll get a list of commits with their details:

Export commit data to CSV directly from Bitbucket

To export raw commit data to CSV directly from Bitbucket, you need to go to the People page. There you’ll notice the Export menu at the top-right corner, where you can choose CSV.

Search for commits in Bitbucket via REST API

Another way to export commit data to CSV is to use the Awesome Graphs REST API, which allows you to automate the processes and retrieve this data easier using the dedicated resources.

You can access the in-app documentation (accessible to Awesome Graphs’ users) by choosing Export → REST API on the People page or go to our documentation website.

Search for commits in Bitbucket via REST API

Bitbucket REST API provides a possibility to get the list of all commits in the repository using this request.

https://example.com/rest/api/1.0/projects/exampleprojectkey/repos/example-repository-slug/commits

The request can be extended by specific parameters to receive a more accurate result. For instance, since and until options help to get the commits made after or before a certain commit, or between two commits defined by their IDs. Merges parameter controls how to handle merge commits – exclude merge commits, include both merge commits and non-merge commits, or only return merge commits.

https://example.com/rest/api/1.0/projects/exampleprojectkey/repos/example-repository-slug/commits?merges=exclude&since=ea3eea9dcbd&until=f4240bf022a

After running the request, you will  receive a JSON response with the list of the commits and their IDs, author’s names and email addresses, commit messages, and parents.

{
    "values": [
        {
            "id": "f4240bf022a69815241a883c03645444b58ac553",
            "displayId": "f4240bf022a",
            "author": {
                "name": "Max Desiatov",
                "emailAddress": "max@desiatov.com"
            },
            "authorTimestamp": 1557113671000,
            "committer": {
                "name": "Tomer Doron",
                "emailAddress": "tomer@apple.com"
            },
            "committerTimestamp": 1557113671000,
            "message": "Add internal section link to README.md (#71)",
            "parents": [
                {
                    "id": "ea3eea9dcbd46887d846696261f54b3d2f74fecd",
                    "displayId": "ea3eea9dcbd"
                }
            ]
        },

Alternatively, you can use the Awesome Graphs REST API that provides global, user, project, and repository data. The solution allows you to retrieve data faster while decreasing the load on the instance compared to Bitbucket REST API. 

Use this request to get a list of commits from the specified repository.

https://example.com/rest/awesome-graphs-api/latest/projects/exampleprojectkey/repos/example-repository-slug/commits

The response will include the list of commits with their IDs, authors’ names and emails, the number of lines of code added and deleted, the project name, and the repository name. It will look as follows:

{
  "values": [
    {
      "user": {
        "emailAddress": "asmith@stiltsoft.com",
        "displayName": "Administrator",
        "name": "admin"
      },
      "author": {
        "displayName": "admin",
        "emailAddress": "asmith@stiltsoft.com"
      },
      "authorTimestamp": "2024-06-05T22:58:18Z",
      "linesOfCode": {
        "added": 1,
        "deleted": 0
      },
      "parents": [],
      "repository": {
        "slug": "Commit Hook",
        "name": "commit-hook",
        "project": {
          "key": "TESTCONTAINERS",
          "name": "Testcontainers",
          "type": "NORMAL"
        }
      },
      "id": "9f2e24a147bb8f5a5a3d10b692703cc5784df8b5"
    },
  ],
}

Learn more about the available REST API resources.

Find out what works best for you

We’ve described different ways to work with commits effectively:

  • Sourcetree as a free application that is suitable for searching among a small number of repositories.
  • Awesome Graphs for Bitbucket add-on as a tool with wide search opportunities and various analytical features.
  • Bitbucket REST API as a more advanced and technically demanding option.

Try them all and find the best solution!

You can also read how other teams benefit from using Bitbucket in a bundle with Awesome Graphs: