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 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.
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 <new.email@example.com> Old Name <old.email@example.com>
This will replace Old Name <old.email@example.com>
in git history with New Name <new.email@example.com>
and these changes will also reflect on Github and Bitbucket.
Also to change authors in Git for a particular project, one may run:
git config user.name "Author Name"
git config user.email "author@email.com"
First of all create two different account into bitbucket
User: jonny_ceg1
User: jonny_ceg2
Now into your computer create two ssh keys;
$ ssh-keygen -t rsa -C “jonny_ceg1/jonny_ceg2″
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
$ ssh-add id_rsa
Now create a file
$ ~/.ssh/config
$ vim ~/.ssh/config # we can use this as editor
Write following code into that file
# Default GitHub user (jonny1)
Host bitbucket.org
HostName bitbucket.org
User jonny_ceg1
IdentityFile /Users/jonny/.ssh/id_rsa
# Client user (jonny2)
Host bitbucket.org
HostName bitbucket.org
User jonny_ceg12
IdentityFile /Users/jonny/.ssh/id_rsa2
by using “IdentityFile”: IdentityFile comment only a single line to avoid jonny_ceg1/jonny_ceg2 as a user
# An Example
## use account 1
# ssh-add ~/.ssh/id_rsa
## use account 2
# ssh-add ~/.ssh/yysshkey
## Check logged in user
# ssh -v git@bitbucket.org
# Default GitHub user (jonny)
Host bitbucket.org
HostName bitbucket.org
User jonny_oct
IdentityFile /Users/name/.ssh/id_rsa
# Client user (name)
Host bitbucket.org
HostName bitbucket.org
User name_last
# IdentityFile /Users/name/.ssh/yysshkey
# Original Git hub
Host github.org
HostName github.org
User ssUsers
ForwardAgent yes