问题
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.
回答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
回答2:
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.
回答3:
you must add origin repo
git remote add origin <url to repo>
see here https://help.github.com/articles/adding-a-remote/
回答4:
Few options
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
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 (orUsers/<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)
- Click on the
SSH keys
- Click on the
Add ssh key
- Paste your key and save
And you all set to go :-)
来源:https://stackoverflow.com/questions/34582407/new-git-repository-error-on-first-push