How to change committed User name in bitbucket?
Solution 1
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 and fetch
ing (or pull
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.
Solution 2
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:
New Name <[email protected]> Old Name <[email protected]>
This will replace Old Name <[email protected]>
in git history with New Name <[email protected]>
and these changes will also reflect on Github and Bitbucket.
Solution 3
Also to change authors in Git for a particular project, one may run:
git config user.name "Author Name"
git config user.email "[email protected]"
Solution 4
git filter-branch
rewrites your history. This can cause problems if you have shared your repository with other people, so be careful!- Make sure you have pushed the result of the
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
! - Sites like Bitbucket and GitHub try to link commits to users instead of simply displaying the commiter's name. This is done by matching the committer's email address to an email address that is associated to one of their users. If you expect Bitbucket to show a link to your user profile, make sure that you have added the new email address to your account. To do so, click on your profile photo in the upper right corner of the site, click 'Manage account', and then in the left sidebar click on 'Email addresses'.
Amrit Dhungana
Updated on June 25, 2022Comments
-
Amrit Dhungana almost 2 years
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='[email protected]' " HEAD
It only change username in local machine but not in my bitbucket account. How to change committed username in bitbucket ?
-
Alexandru Guzinschi almost 9 yearsPlease see this answer for a solution to change authors in Git without rewriting your history.
-
Chris almost 9 years@AlexandruGuzinschi, nice solution!