2014-05-02 41 views

回答

3

和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会拒绝推送。

+1

请参阅[this](http://stackoverflow.com/a/30373772/1459926)解决方案,以便在不改写历史记录的情况下更改Git中的作者。 –

+0

@AlexandruGuzinschi,很好的解决方案! – Chris

1
  1. git filter-branch重写你的历史。如果您与其他人共享您的存储库,这可能会导致问题,所以要小心!
  2. 确保已将filter-branch操作的结果推送到远程存储库。既然你已经搞砸了历史提交,你可能需要使用git push -fgit push(没有-f)会注意到你的本地和远程分支已经发生分歧,这是因为你已经改写了你的历史。再次,在使用git push -f之前要小心!
  3. 像Bitbucket和GitHub这样的站点尝试将提交链接到用户,而不是简单地显示提交者的名称。这是通过将提交者的电子邮件地址与与其中一个用户相关联的电子邮件地址进行匹配来完成的。如果您希望Bitbucket显示您的用户个人资料的链接,请确保您已将新的电子邮件地址添加到您的帐户。为此,请点击网站右上角的个人资料照片,点击“管理帐户”,然后点击左侧栏中的“电子邮件地址”。
0
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