Thursday, December 3, 2015

Changing the author name for git/gerrit commit

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'

Now,
$ 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 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 "

No comments:

Post a Comment

You are welcome to provide your opinions in the comments. Spam comments and comments with random links will be deleted.