Big Daddy
Big Daddy

Reputation: 5234

Add existing project to GitHub

I've got an existing project that I need to add to GitHub. I've got a local repo created and need to push it to new remote in GitHub. My company uses GitHub for source control, so is this a "private" repo? Anyway, I followed the steps outlined here and get "Repository no found". What am I missing? This is not something I have much experience with.

git remote add origin https://myGitHubUrl/projectName ----COOL
git remote -v ----COOL
    *origin https://myGitHubUrl/projectName (fetch)*
    *origin https://myGitHubUrl/projectName (push)*
git push origin master ----NOT COOL
    *remote: Repository not found.*

EDIT I missed the first step that says:

Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.

It works now. ALWAYS READ THE DOCS!!

Upvotes: 0

Views: 1186

Answers (2)

Nisarg
Nisarg

Reputation: 1641

1) if you are trying to connect your local repo to a remote via https. If this is the case then the following commands should fix the issue for you:

$ git remote -v
origin  https://github.com/private-repo.git (fetch)
origin  https://github.com/private-repo.git (push)
$ git remote rm origin
$ git remote add origin [email protected]:private-repo.git
$ git remote -v
origin  [email protected]:private-repo.git (fetch)
origin  [email protected]:private-repo.git (push)

2) Remove the remote origin

git remote rm origin

re-add the origin but with your username and pwd with writing privileges on this pvt repo

git remote add origin  https://USERNAME:[email protected]/username/reponame.git

3) You have configured ssh key

#check current github account
ssh -T [email protected]

#ensure the correct ssh key used with github
ssh-agent -s
ssh-add ~/.ssh/YOUR-GITHUB-KEY

#re-add the origin
git remote add origin [email protected]:YOUR-USER/YOUR-REPO.GIT
git push -u origin master

4) you might need to try solved it by including my username and password in the repo url:

git clone https://myusername:[email protected]/path_to/myRepo.git

Note: This detailed step might help you and am considering you don't have repo created in github.

Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.

    git init
    git add .
    git commit -m "First commit"

    # Sets the new remote
    git remote -v
    # Verifies the new remote URL
    git push origin master

If it's exisiting github repo, then do following steps.

cd existing_repo
git remote rename origin old-origin
git remote add origin <url>
git push -u origin --all
git push -u origin --tags

Upvotes: 1

gmolaire
gmolaire

Reputation: 1121

Create the repository in github first and make sure the URL you use while configuring your local repository matches the one configured in github.

If you still have the same issue after creating the repository, take a look at their help page regarding this issue: Here

Be aware that the help page uses SSH and not HTTPS. You may remain with the HTTPS protocol. Just copy the full link from what they provide on the repository page after you create it (by selecting HTTPS as your protocol) to be on the safe side.

Upvotes: 2

Related Questions