I had one existing account with Github and the source are getting pushed to old account, but i need to switch that to another new one (some private issue and public issue).
$ 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.
How to resolve it?
Follow up:
Admin | switch from public repo to | his own private repo | push himself
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...
Third party developers | get access to push | Admin private repo
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
Looks like you already have a remote named origin. Delete it, then recreate it.
If you want to see why it’s failing though, check out .git/config and you’ll see the old remote in there. An alternative way to do the same as the above two commands do would be to edit that file.