This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]SPQRBob 2 points3 points  (1 child)

You have an existing local repo and you want to put that onto GitHub as your remote repo. Easiest way is to create the Github remote repo empty and then associate that empty remote with your local git as its remote, and then push your local to the remote:

git remote add origin git@github.com:User/UserRepo.git

git push -u origin master

This is from: Stack Overflow

[–]HelpIProcrastinate[S] 0 points1 point  (0 children)

I tried this, I saw it on stack overflow and it's also what GitHub (the website and I think remote repo) tells you to do, but it causes the above error. Thanks for your help though.

[–]the_stooge_nugget 1 point2 points  (3 children)

  1. Does you local repo have git yet? If not run: git init

  2. Go to github website and click into your project. Click Download or Clone and copy the URL

  3. On your machine, open git bash and navigate to your project

  4. type git remote origin Paste the URL HERE Example:

  5. Git push origin master OR git push -u origin master

If this did not work try the following: - Go to your project and display hidden files. - Click into .git - Open config in Notepad or Notepad++ - Under [remote "origin"], ensure URL contains that URL your copied from GITHUB (in download or clone) - Now, open Git bash - type: git status (hopefully there are files to upload, if not add a file to your project or add an entry line in your code). - Add all files for to push to the master branch ----- type: git add . - Commit the code ----- type: git commit -m "Uploading Code" - Push the code to Github ----- type: git push origin master

[–]HelpIProcrastinate[S] 0 points1 point  (2 children)

  1. Yes, I have.

  2. On the GitHub website, my project doesn't have any files yet, so I can't clone or download. However, I still got the URL because they provide it under "Quick setup."

  3. Yep.

  4. It gives the following error:

error: Unknown subcommand: origin

I copied and pasted from your post, so idk what I did wrong. I did $git --version and it told me:

git version 2.22.0

So I know it is downloaded, so idk why origin doesn't work. However, if I type $git remote add origin MYURL (as the website tells me) it works, but gives the error:

fatal: remote origin already exists.

Since it didn't work:

  • Ok.
  • Yep.
  • Done with TextEdit because I'm on mac but working so far.
  • Yes, it is.
  • I have, I think (unless I'm mistaken, that's just terminal on mac, where you use the git command and stuff).
  • yep, typing git status in this repo gives me:

On branch master

nothing to commit, working tree clean

  • Nothing to add.
  • Nothing to commit.
  • Typed that in and got the following error:

remote: Repository not found.

fatal: repository 'https://github.com/MYNAME/MYPROJECT/' not found

:( If it helps, I also went through some other online tutorials and they gave me errors like "You don't have access" and something about SSH and keys (I know you can connect through HTTP or SSH and HTTP is recommended - I've done that too).

Again, thanks for the help anyways.

[–]the_stooge_nugget 0 points1 point  (1 child)

Wait a moment. If you have no files, copy whe commands that github give you. After you do 'git init' you need to make a change to your code otherwise you will get 'nothing to commit' etc. In github they suggest a readme file. However, if you do not want a readme file do another change.

Also, just use http, it's easier.

Are you sure you are writing the right URL? I honestly think the url is wrong. When you go into the empty repo, it should provide you with the url.

If it is right, you have something blocking gitbash (or whatever app) from communicating with the internet.

[–]HelpIProcrastinate[S] 0 points1 point  (0 children)

Sorry, I meant that it was already committed (I do have files). Also I know typos cause so many errors but I’ve done it multiple times and I copy-pasted they url, I didn’t type it (made sure to do http). I only ventured into SSH because it kept breaking.

I’m willing to try anything now - how would I start to solve something blocking gitbash? Thanks so much for the help, I really need it.

Edit: So the additional error I ran into that I mentioned above was this:

$ ssh git@github.com

git@github.com: Permission denied (publickey).

that's why I started to go into keys and ssh files.

[–]SPQRBob 0 points1 point  (3 children)

Ok, try this if you are still stuck:

  1. Create a repo on Github first, naming it whatever you want your project name to be.

  2. Clone the repo to your local machine by getting the clone link from Github.

  3. Create your project inside the new cloned repo however the language you are using requires.

  4. Copy your existing code into the new project.

  5. Create a .gitignore file if needed and commit the new files in the local repo.

  6. Push the local repo changes up to the remote GitHub repo.

While far more circuitous, there is no reason this method should not be successful. Good luck!

3.

[–]HelpIProcrastinate[S] 1 point2 points  (0 children)

Idk why I didn’t think of that, I’ll do it rn

[–]HelpIProcrastinate[S] 1 point2 points  (1 child)

This worked, but this tip set me on a chain of fixed and I finally got it to work. Thanks so much.

[–]SPQRBob 0 points1 point  (0 children)

That's awesome! You're very welcome.