14

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. 
2

8 Answers 8

31

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.

Sign up to request clarification or add additional context in comments.

1 Comment

on doing this which way is the data going I have mine locally and do not want to over write them doing it the wrong way around!
8

try this

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

then try to again

git push -u origin master 

Comments

5
git remote add origin <url> 

then

git push -u origin master 

Comments

2

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.

Comments

0

Run below command

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

no SSH please!

Comments

0

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 !!!

1 Comment

Please add text where explain your code and say, what this two commands do!
0

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

Comments

-2

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!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.