如何更改bitbucket帐户中的提交用户名?要在Git中改变我已经使用这个命令如何在bitbucket中更改提交的用户名?
git filter-branch -f --env-filter " GIT_AUTHOR_NAME='newUser' GIT_AUTHOR_EMAIL='[email protected]' " HEAD
只更改用户名在本地计算机上,但不是在我的帐户到位桶。如何更改bitbucket中提交的用户名?
如何更改bitbucket帐户中的提交用户名?要在Git中改变我已经使用这个命令如何在bitbucket中更改提交的用户名?
git filter-branch -f --env-filter " GIT_AUTHOR_NAME='newUser' GIT_AUTHOR_EMAIL='[email protected]' " HEAD
只更改用户名在本地计算机上,但不是在我的帐户到位桶。如何更改bitbucket中提交的用户名?
和Git一样(几乎)其他所有东西,这个命令只会修改你的本地仓库。就像您提交或添加标签时一样,您必须推送到BitBucket才能使更改显示出来。
但是在你做之前,要确定你想要的。
您运行的filter-branch
命令重写了您的历史记录。您的每个提交现在都有一个新的散列。这是considered bad practice to rewrite history that has been shared with others,如果你推到BitBucket你会这样做。
这可能会导致真正的问题,最显然的是因为任何其他已经克隆存储库的人现在的历史记录将不再反映在存储库中。他们将遇到问题push
ing和fetch
ing(或pull
ing)。如果您选择继续前进,最好谨慎并诚实地与您的所有合作者沟通。
如果您是非常非常确定您想要这样做,您必须使用--force
选项来推送,否则BitBucket会拒绝推送。
git filter-branch
重写你的历史。如果您与其他人共享您的存储库,这可能会导致问题,所以要小心!filter-branch
操作的结果推送到远程存储库。既然你已经搞砸了历史提交,你可能需要使用git push -f
。 git push
(没有-f
)会注意到你的本地和远程分支已经发生分歧,这是因为你已经改写了你的历史。再次,在使用git push -f
之前要小心!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 [email protected]
# 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
就像Chris说的,重写你的git历史是一个糟糕的做法。
映射作者的推荐方法是使用.mailmap功能。
在与下列内容存储库的顶层创建.mailmap
文件:
New Name <[email protected]> Old Name <[email protected]>
这将提交历史与New Name <[email protected]>
取代Old Name <[email protected]>
而这些变化也将反映在Github和到位桶。
请参阅[this](http://stackoverflow.com/a/30373772/1459926)解决方案,以便在不改写历史记录的情况下更改Git中的作者。 –
@AlexandruGuzinschi,很好的解决方案! – Chris