Over a million developers have joined DZone.

Changing the Author Name for a Git or Gerrit Commit

DZone 's Guide to

Changing the Author Name for a Git or Gerrit Commit

How to get around a failed commit due to a merge with remote repository and local code changes.

· Agile Zone ·
Free Resource

So this was my second time having some adventure with gerrit for OpenDaylight (also read about the first time, if you are curious). This time, I pulled the remote changes and tried to commit my new changes by adding my changes. This created a merge as the commit from the remote repository and my local commits merged in a single pull request, and hence my commit failed with the below message.

$ git review

You are about to submit multiple commits. This is expected if you are
submitting a commit that is dependent on one or more in-review
commits. Otherwise you should consider squashing your changes into one
commit before submitting.

The outstanding commits are:

fe17631 (HEAD, master) Fix bug 4535/4541
475fae6 Use odlparent-lite as artifacts parent

Do you really want to submit the above commits?
Type 'yes' to confirm, other to cancel: yes
remote: Processing changes: refs: 1, done    
To ssh://pradeeban@git.opendaylight.org:29418/messaging4transport.git
 ! [remote rejected] HEAD -> refs/publish/master/bug/4535 (you are not allowed to upload merges)
error: failed to push some refs to 'ssh://pradeeban@git.opendaylight.org:29418/messaging4transport.git'


$ git statusOn branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

So it indeed shows as 2 commits - one mine, and the one pulled from the remote repository.

I had to rebase to the master to fix this.

$  git rebase origin/master

However, this left my commit attributed to the author of the previous commit, in the commit log when I try to git review.

I had to amend the author to finally fix the commit message successfully git review following that.

$ git commit --amend --author "FirstName LastName"


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}