tags:

views:

1099

answers:

4
+2  Q: 

git new repository

ppl,

I have put my project on github at some location [email protected]:myname/oldrep.git. Now I want to push all my code to a new repository at some new location [email protected]:newname/newrep.git...

so I used the command

git remote add origin [email protected]:myname/oldrep.git

but I am receiving this

fatal: remote origin already exists.

Please help me

+5  A: 

You are getting this error because "origin" is not available. "origin" is a convention not part of the command. "origin" is the local name of the remote repository.

For example you could also write:

git remote add myorigin [email protected]:myname/oldrep.git
git remote add testtest [email protected]:myname/oldrep.git

See the manual:

http://www.kernel.org/pub/software/scm/git/docs/git-remote.html

MrHus
A: 

You could also change the repository name you wish to push to in the REPOHOME/.git/config file

(where REPOHOME is the path to your local clone of the repository).

nolim1t
A: 

You can simply edit your config file in a text editor.

In the ~/.gitconfig you need to put something like the following:

[user]
        name  = Uzumaki Naruto
        email = [email protected]

[github]
        user = myname
        token = ff44ff8da195fee471eed6543b53f1ff

In the oldrep/.git/config file (in the config file of your repository):

[remote "github"]
        url = [email protected]:myname/oldrep.git
        push  = +refs/heads/*:refs/heads/*
        push  = +refs/tags/*:refs/tags/*

If there is remote section in your repository's config file, and url matches, you need only to add push configuration. If you use public url for fetching, you can put url for pushing as 'pushurl' (warning: this requires just released git version 1.6.4).

Jakub Narębski
+1  A: 

If you have mistakenly named the local name as "origin", you may remove it with the following:

git remote rm origin
Comptrol