Kelly
Kelly

Reputation: 163

fatal- 'origin' does not appear to be a git repository

I created a remote repo then create a local one locally:

git init

then added the files i need using git add then git commit -m "something"

finally git push origin master

I got this error fatal:

'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

should i like the remote and local in some command or something? and if so is it ok if i already added and commited or should i start over locally?

EDIT:

Apparently i should add git remote add origin ssh://[email protected]:1234/myRepo.git but what should i replace that ssh with as in where can i find my version of what i should add.

Got this error :

! [rejected]        master -> master (fetch first)
error: failed to push some refs to 
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Upvotes: 14

Views: 89920

Answers (8)

Richard Nguyen
Richard Nguyen

Reputation: 1

I got the following error when I tried to upload the code with git push origin <branch> command:

fatal: 'orgin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

try this

git remote add origin <https://github.com/"username"/"repository".git>

then try to again

git push -u origin master

I took a reference from this programmer: Hồ Kim Long Sơn

Upvotes: 0

kush
kush

Reputation: 190

first you need to run this command:

git remote add origin https://github.com/"USERNAME"/"REPOSITORY_NAME".git

after that this:

git push -u origin "branch name"

This will work !!!

Upvotes: 0

Jackson
Jackson

Reputation: 159

Run below command

git remote add origin [email protected]:xxxx/xxxx.git

no SSH please!

Upvotes: 0

Hồ Kim Long Sơn
Hồ Kim Long Sơn

Reputation: 101

try this

git remote add origin <https://github.com/"username"/"repository".git> 

then try to again

git push -u origin master

Upvotes: 8

ElpieKay
ElpieKay

Reputation: 30956

When you run git clone <repo_url> to clone a repository, the default remote origin is created automatically. If the repository is created by git init, there is no default remote, no origin. You need to set it up by yourself.

git remote add origin <repo_url>

repo_url is the path to an existing remote repository which you want to exchange data with . If it's in the local disk, it could be file:///home/me/foo.git or /home/me/foo.git. If it's hosted in Github, it could be https://github.com/me/foo.git or ssh://[email protected]/me/foo.git.

As to the 2nd error about "fetch first". You need to run git pull origin <branch> or git pull -r origin <branch> before a next push.

Upvotes: 31

Okpo
Okpo

Reputation: 417

I had this same error message while trying to do a PR. On a critical look, I realized I was carrying out the Git workflow on a wrong directory.

In my case, I simply went back a step to the right dir using **cd..** and then proceeded with no more error.

Upvotes: 2

shaher11
shaher11

Reputation: 140

git remote add origin <url>

then

git push -u origin master

Upvotes: 5

Ally Makongo
Ally Makongo

Reputation: 269

This happens because your config file contains master word instead of heroku git url. This might happen when you initialize git more than once.

  1. Edit the config file

    git config --e

  2. Then edit master word to heroku url e.g. https://git.heroku.com/project_name.git

  3. Save it wq!

  4. Then push update by git push heroku master

I hope this will help you!

Upvotes: -2

Related Questions