Commit in Bitbucket Server shows a different username than the one that pushes the code

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Frequently, new Bitbucket Server users believe that the user that pushes changes to Bitbucket Server should be listed in the Author column of the commits displayed in the UI. Take, for example, the following screenshot:

While the Author column displays "Integration Builder," the user who performed the commit, the user who pushed the code to the repository was a different user, "Test1".

Environment

Bitbucket Server and Data Center (version 2.12+)

Diagnosis

  1. First, check your git configuration to see if the email address set on your git config file matches the email address specified on your Bitbucket user profile.

    $ git config -l
  2. If the email address set on your git configuration file seems to match the email address specified on your profile, run the following SQL command on the database of the Bitbucket Server instance:

    $ SELECT * from cwd_user WHERE lower_email_address LIKE '%your_email_address%';

    (warning)Suppose the SQL command comes up with more than one result. In that case, this shows that your email address is, for some reason, associated with multiple accounts on your Bitbucket instance – possibly caused by having two users in different user directories on the Bitbucket Server.
    (warning)If the SQL command comes up with zero results while the user with this email exists in Bitbucket, this shows that the user's email address may have spaces or other non-printable symbols.

Cause

The user displayed in the "Author" column is the user that committed changes to the local repo, which occurs before the data is pushed to Bitbucket server. The configuration happens on the local Git client.

The Bitbucket Server user who pushed the changes is not displayed anywhere in the UI in Bitbucket older than 6.9. In Bitbucket 6.9 and newer, you can see the Avatars of both the committer and user who pushed under the Author column, as shown below.


In the case of spaces in the email, the issue mostly comes from LDAP.

Solution

Case 1: The email address set in the git config does not match the email address on your Bitbucket server:

Suppose your email address specified on your git configuration file does not match the email address specified on your Bitbucket Server user profile. In that case, this is expected behavior, and you need to configure your local Git client accordingly. If you want to see a different user on that column, you must update your Git configuration and perform a new commit:

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com


For more details, please refer to
Atlassian Git microsite.

Case 2: Email address in git config matches with an email address on Bitbucket:

If the email address set on your git configuration file matches the email address specified on your Bitbucket Server user profile, the SQL command mentioned in the 'Diagnosis' step returns more than one result. In this case, multiple user accounts share the same email address. Bitbucket Server will pick the first user returned with this email address based on alphabetically sorting the usernames that belong to that email address. The solution is to change the email address associated with the other user accounts.

  • From the SQL command output, note the username(s) associated with your email address.
  • Change the email address of the Bitbucket user(s) associated with your email address (either from Bitbucket Server or your external user directory) – leave out the one user you want associated with your email address.

Bear in mind that as of Bitbucket Server 2.12, we have been supporting "username linking" - when you're logged in to Bitbucket Server, you'll notice that wherever commit author names are displayed (for example, on the commits list and the blame view) they are now linked to the profile page of the author (if the author is also a Bitbucket Server user). Authors are matched to Bitbucket Server users via the author's email address, and the user's name in their Bitbucket Server account is displayed instead of their git author name.

For reference:

If the resolution does not work, please get in touch with Atlassian Support.

DescriptionThis article discusses an issue where a commit in Bitbucket server shows a different username than the one that pushes the code.

Last modified on Nov 28, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.