2

I need SOS help, I committed a project to bitbucket and committed by my name but I need to change the author name (and the email address).

bitbucket

What's the easiest way to do that?

phd
  • 82,685
  • 13
  • 120
  • 165
Devy
  • 703
  • 6
  • 17
  • Possible duplicate of [How to change the author and committer name and e-mail of multiple commits in Git?](https://stackoverflow.com/questions/750172/how-to-change-the-author-and-committer-name-and-e-mail-of-multiple-commits-in-gi) – phd Jun 23 '19 at 19:57
  • https://stackoverflow.com/search?q=%5Bgit%5D+change+commit+email – phd Jun 23 '19 at 19:57

1 Answers1

3

You can simply amend your last commit and push (forced)

git commit --amend --author="Your name <yourEmail@example.com>"
git push --force 

As commented by [OznOg], if git config user.name and git config user.email are showing the right values, a --reset-author is enough:

git commit --reset-author 
git push --force

Your branch is ahead of 'origin/master' by 2 commits.

So the latest commit on BitBucket is not the latest locally: you have made two other commits.

First check if you can reset the one from bitbucket.

git checkout -b tmp
git reset --hard origin/master
git commit --amend --author="Your name <yourEmail@example.com>"
git push --force

If what you see if OK, then you can apply your two next commit:

git cherry-pick tmp~1
git commit --amend --author="Your name <yourEmail@example.com>"

git cherry-pick tmp
git commit --amend --author="Your name <yourEmail@example.com>"

git push
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @OznOg True. I have included your comment in the answer for more visibility. – VonC Jun 23 '19 at 14:34
  • After I run the first line it tells I have conflicts, how to fix? – Devy Jun 23 '19 at 14:36
  • @Devy Did you made any git pull between the time you have pushed and now? Do you have any work in progress? What is the output of `git status`? – VonC Jun 23 '19 at 14:39
  • Output of `git status` is: On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits) nothing to commit, working tree clean – Devy Jun 23 '19 at 14:48
  • Hi, when I run the cherry pick command I get `error: Cherry-picking is not possible because you have unmerged files.` – Devy Jun 23 '19 at 17:26
  • @Devy check your git status first: as long as it is not "clean", as long as it lists files with possible conflicts, you should not cherry-pick. – VonC Jun 23 '19 at 17:44