2

I did git init, then I realized I should include the link that I got when I made the repository in GitHub so I did this:

git init https://github.com/genadinik/AndroidMakeMoneyFree.git 

Then I did:

git add -all git commit -m "Adding repository contents" 

And that worked fine, but then I tried to push and got this error:

git push origin master 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. 

4 Answers 4

4

As far as I know, you should not include the url of the GitHub (or other git server) repository in the git init. Git is distributed: you can add several remotes.

You initialize a git repository with:

git init 

(optionally followed by the directory, if omitted, the current directory is used).

Then you can add a remote as follows:

git remote add origin https://github.com/genadinik/AndroidMakeMoneyFree.git 

(or another url)

Here you add a remote you call origin. Mind that you can give it another name. You can also decide to add multiple remotes like GitHub, BitBucket, GitLabs, CodePlex,... and push your local copy to all of those remotes.

and then you can push to the origin or other remote.


If however GitHub already contains files, you better make a git clone, and work with the clone.

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

Comments

1

I don't think git init accepts a URL (although I could be wrong).

To add a remote repository run the following

git remote add origin https://github.com/genadinik/AndroidMakeMoneyFree.git 

and for the first push you should use the following command to ensure all tags and such are pushed up.

git push -u origin --all 

1 Comment

I got this error on the first command: fatal: remote origin already exists.
1

you must add origin repo

git remote add origin <url to repo> 

see here https://help.github.com/articles/adding-a-remote/

2 Comments

it kind of worked, but got this conflict CONFLICT (add/add): Merge conflict in .gitignore Automatic merge failed; fix conflicts and then commit the result.
git status, resolve conflicts, git add, then git commit -a
0

Few options

  1. You do not have a remote.
    git init doesnt set the remote so you have to add it manually.

     git remote add origin https://github.com/genadinik/AndroidMakeMoneyFree.git 
  2. You do not have ssh keys Generate ssh keys and change the remote url form HTTPS to ssh/git

You need to ssh keys:


Simply follow those steps and you will set up your ssh key in no time:

  • Generate a new ssh key (or skip this step if you already have a key)
    ssh-keygen -t rsa -C "your@email"

  • Once you have your key set in home/.ssh directory (or Users/<your user>.ssh under windows), open it and copy the content


How to add sh key to github account?

  • Login to github account
  • Click on the rancher on the top right (Settings)
    github account settigns
  • Click on the SSH keys
    ssh key section
  • Click on the Add ssh key
    Add ssh key
  • Paste your key and save

And you all set to go :-)

1 Comment

This has not much to do with the problem I think: git complaints it can't find a remote named origin, regardless whether that is GitHub or another one.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.