best git commit graph for atlassian bitbucket server

Git - Adjusting Authorship Info

You have probably arrived at this webpage because your Control Freak - Commit Checkers and Jira Hooks for Bitbucket plugin is configured to reject commits where the author name and email do not exactly match the corresponding name and email values stored in Bitbucket's user directory.

The good news: adjusting authorship data in a branch's tip commit is easy!

The bad news: adjusting authorship data in commits behind the tip (older commits) is much harder.

Set Your Local Git Config First

Make sure your git config has proper name and email values that match user records in Bitbucket's user directory! Like so:

git config --global "User Name" 
git config --global

Adjusting The Tip Commit

The following command will rewrite the current branch's tip commit object. The "--reset-author" flag injects the latest name and email data from your git config:

git commit --amend --reset-author

Adjusting Older Commits

There are two approaches:

  1. Squash Method: Squash your branch into a single tip commit, and then use the much easier "Adjusting The Tip Commit" technique above. There are several ways to squash a branch. I recommend the following squash technique based on git reset --soft:
    git reset --soft $(git merge-base HEAD @{upstream})
    git commit

    Note: the "@{upstream}" reference above is a valid git reference and not a placeholder, and is meant to be copied verbatim. Run the "git help gitrevisions" command to learn more about this type of git reference.
  2. Interactive Rebase Method: Run an interactive rebase ("git rebase --interactive"), and mark every commit with "e" or "edit". The rebase will halt for each commit. Every time the rebase halts type the following commands:
    git commit --amend --reset-author --no-edit
    git rebase --continue
    The first of those commands injects your updated authorship metadata into the current commit. Keep typing those two commands (both together each time) until you finally see the message "No rebase in progress?".