How to change commit username in bitbucket account ? To change in git I have used this command
git filter-branch -f --env-filter " GIT_AUTHOR_NAME='newUser' GIT_AUTHOR_EMAIL='newuser@email.com' " HEAD
It only change username in local machine but not in my bitbucket account. How to change committed username in bitbucket ?
Like (almost) everything else with Git, this command only modifies your local repository. Just like when you commit or add a tag, you will have to push to BitBucket in order to make the changes show up.
But before you do, be very sure that you want to.
The
filter-branch
command that you ran rewrote your history. Each of your commits now has a new hash. It is considered bad practice to rewrite history that has been shared with others, and if you push to BitBucket you'll be doing that.This can cause real problems, most obviously because anybody else who has cloned the repository will now have history that is no longer reflected in the repository. They will have trouble
push
ing andfetch
ing (orpull
ing). If you choose to go forward, it is best to carefully and honestly communicate with all of your collaborators.If you are very, very sure that you want to do this, you'll have to use the
--force-with-lease
option to push, or else BitBucket will reject the push.git filter-branch
rewrites your history. This can cause problems if you have shared your repository with other people, so be careful!filter-branch
operation to the remote repository. Since you have messed with historic commits, you probably need to usegit push -f
for this.git push
(without-f
) will notice you of the fact that your local and remote branches have diverged, this is because of the fact that you have rewritten your history. Again, be careful before you usegit push -f
!Also to change authors in Git for a particular project, one may run:
Like Chris said, it is a bad practice to rewrite your git history.
The recommended way to map authors is to use the .mailmap feature.
Create a
.mailmap
file at the top level of your repository with the following content:This will replace
Old Name <old.email@example.com>
in git history withNew Name <new.email@example.com>
and these changes will also reflect on Github and Bitbucket.