I am following the instructions given here to create a Git repository. All went well until the last line:
$ git push -u origin master
May be you forgot to run "git --bare init
" on the remote?
That was my problem
As it has already been mentioned in che's answer about adding the remote part, which I believe you are still missing.
Regarding your edit for adding remote on your local USB drive. First of all you must have a 'bare repository' if you want your repository to be a shared repository i.e. to be able to push/pull/fetch/merge etc..
To create a bare/shared repository, go to your desired location. In your case:
$ cd /Volumes/500gb/
$ git init --bare myproject.git
See here for more info on creating bare repository
Once you have a bare repository set up in your desired location you can now add it to your working copy as a remote.
$ git remote add origin /Volumes/500gb/myproject.git
And now you can push your changes to your repository
$ git push origin master
To resolving this problem.I just create a new folder and put some new files.Then use these commond.
* git add .
* git commit
* git remote add master `your address`
then it tells me to login in. To input your username and password. after that
git pull
git push origin master
finished you have pushed your code to your github
Setting remote repository URL worked for me:
git remote set-url origin https://github.com/path-to-repo/MyRepo.git
I'll still share my short answer humbly, knowing that I'm super late to answer this question.
Here's, a simple and clean explanation that solved my issue
Also, since I was using the SSH key I used the following command:
for instance it would look like:
If you are using the HTTPS URL, refer to the answer provided by @sunny-jim above.
Do correct me if I'm wrong. Thanks.
my case was a little different - unintentionally I have changed owner of git repository (project.git directory in my case), changing owner back to the git user helped