Reputation: 593
I have simply created a repository in github. Using the commands I am trying to upload a project to my new repository. But giving me errors after this command:
git remote add origin https://github.com/nafeeur10/rental.git
Error:
fatal: remote origin already exists.
Then
git push -u origin master
Error:
[email protected]: Permission denied (publickey). and the repository exists.
What is the problem and what should I do actually?
Upvotes: 3
Views: 2124
Reputation: 1
Your remote origin exists. So you are probably getting this error because you didn't initialize or reinitialize(in case of a new commit in previously existing repository) your git repository. First type command "git init". After that try this command.
git push -u origin master
Then you might be prompted for authentication. Provide your credentials and changes will be pushed to your remote repository.
Upvotes: 0
Reputation: 687
fatal: remote origin already exists.
This error message indicates remote is already configured with the same name. Either add the new remote with a different name or update the existing one.
To set new remote:
$ git remote set-url origin https://github.com/nafeeur10/rental.git
Or can update existing one:
git remote add origin1 [email protected]:ppreyer/first_app.git
Doing so, everywhere in "origin" you should replace it with "origin1". For example $ git push origin master should now be $ git push origin1 master.
Upvotes: 3
Reputation: 374
1.If origin url is already added, you can use "git remote -v " to see what origin is already added.
Since you have origin already set to some url, you can update origin url using
git remote set-url origin https://github.com/nafeeur10/rental.git
2.You might not have permission to push to master branch. Try pushing to new develop branch.
Upvotes: 3