Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将git存储库切换到另一个新帐户?_Git_Version Control_Netbeans_Github - Fatal编程技术网

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

如何将git存储库切换到另一个新帐户?,git,version-control,netbeans,github,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 origi

我在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

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

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

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

如果只是更改url,则可以设置url