如何将我的git存储库切换到另一个新帐户?

时间:2012-01-18 18:42:32

标签: git version-control netbeans github

我在Github有一个现有帐户,而且来源被推到旧帐户,但我需要将其转换为另一个新帐户(一些私人问题和公共问题)。

$ git config --global user.name mynewprivate
$ git config --global user.email mynewprivate@myemail.com
$ git remote add origin git@github.com:mynewprivate/mynewprivaterepo.git
fatal: remote origin already exists.

如何解决?

跟进:

管理员|从公共回购切换到|他自己的私人回购|推开自己

1) I created the key files, private and public.

$ ssh-keygen -t rsa -C "themail@ofyours.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sun/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/sun/.ssh/id_rsa.
Your public key has been saved in /home/sun/.ssh/id_rsa.pub.
The key fingerprint is:
c3:1a:88:49:0e:0b:d0:2 themail@ofyours.com
The key's randomart image is:
+--[ RSA 2048]----+
|o+o              |
|E..+             |
|=++ .            |
|+Xoo . .         |
|=.* . . S        |
| o     o .       |
|      .          |
|                 |
|                 |
+-----------------+

2) I copied it for backup if i lose it i can use it

$ cp -R /home/sun/.ssh/id_rsa to /var/tmp/myprojectname.backup.key

3) I went to github and created the public key from there site (SSH Public key)

4) Then i tested if my system can communicate with git

$ ssh -T git@github.com
Hi {hubname}! You've successfully authenticated, but GitHub does not provide shell access.

    It works!

5) Project upload

$ cd /var/www/html/myprject
$ git remote rm origin
$ git remote add origin git@github.com:myproject/myproject.git

6) I followed as usual my IDE, now to load myproject.git and the private
key that i saved in my /var/tmp/myprojectname.backup.key
7) It started pushing, means uploading success...

第三方开发商|获得推送的权限管理私人仓库

1) Admin adds your username in to there private repo
2) In your personal username you get notice that you are allowed
3) You accept and find the repository details in your own account
4) You do following:

$ ssh-keygen -t rsa -C "youremail@mail.com"
  save the file to /var/tmp/yourproject.name.key
$ cd /var/www/html/localproject
$ git init
$ git remote add origin git@github.com:private/private.git

5) Now you can push to the private repo

1 个答案:

答案 0 :(得分:6)

看起来您已经拥有一个远程命名来源。删除它,然后重新创建它。

git remote rm origin
git remote add origin git@github.com:mynewprivate/mynewprivaterepo.git

如果你想知道它失败的原因,请查看.git / config,你会在那里看到旧遥控器。与上述两个命令相同的另一种方法是编辑该文件。

相关问题