Reputation: 1466
So I'm trying to use Github for the first time. I'm working on a repository that was created for me by the project leader.
I went to my desired directory
/Users/abrahammathew/Desktop/my_issues
I created the directory.
Abrahams-MBP:abiomed_issues abrahammathew$ git clone https://github.com/ml_projects/my_repo.git
...
Checking connectivity... done.
Initializing was done
Abrahams-MBP:my_issues abrahammathew$ git init
Added the files to my local repository
Abrahams-MBP:my_issues abrahammathew$ git add my_data_extraction.py
Commited for the first time
Abrahams-MBP:my_issues abrahammathew$ git commit -m "first commit"
Remotely added the origin.
Abrahams-MBP:abiomed_issues abrahammathew$ git remote add origin https://github.com/abmathewks/my_repo.git
Finally, I tried to push the file to github.
Abrahams-MBP:my_issues abrahammathew$ git push -u origin master
remote: Repository not found.
fatal: repository 'https://github.com/abmathewks/my_repo.git/' not found
So the final step isn't working. Can anyone help diagnose this issue. I've specified the right repo, so I'm not sure why it's not found. Here's my local directory and it's contents.
Abrahams-MBP:my_issues abrahammathew$ ls -a
. my_data_extraction.py
.. my_explore.py
.DS_Store my_repo
.git
Also tried this:
Abrahams-MBP:my_issues abrahammathew$ git push -u origin:master
ssh: Could not resolve hostname origin: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
And a generic push
Abrahams-MBP:my_issues abrahammathew$ git push
remote: Repository not found.
fatal: repository 'https://github.com/abmathewks/my_repo.git/' not found
Upvotes: 1
Views: 112
Reputation: 83577
Part of the problem is that you are doing several unnecessary steps. It is possible that some of these are conflicting with each other.
To create an empty repo from scratch, you use
$ git init
To connect this new repo to an existing one, then you can do
$ git remote add <name> <URL>
On the other hand, you do not need to do either of these two steps when you clone a repo with
$ git clone <URL>
This automatically initializes the directory for use with git and sets up a remote named origin
which refers to the given URL. If you want to add other remotes, then you can use git remote add
with a name other than origin
.
If you want to copy an existing repo from GitHub, you have two options:
Fork the GitHub repo to create your own personal copy. Then git clone
that copy to your local machine to work with. Use the URL for your fork.
git clone
the original GitHub repo with the URL from the original repo. Then create a new personal repo. You can either change the remote URL for origin
:
$ git remote set-url origin <URL>
or add a new remote to point to your new blank repo:
$ git remote add my-personal-repo <URL>
After creating the repository correctly, do these commands as needed:
$ git add <file name>
$ git commit -m 'Some message'
$ git push
Upvotes: 3