0

I need to publish a Github repository from a directory on my computer.

I added, committed, and pushed the origin master of the files I wanted to publish from the root directory of my project. By that, I mean I clicked the "create a new repository" button and typed all the git commands in my terminal while in the project directory I want to publish as my repository. For a list of the commands I used, see the below section labeled "Code."

I saw no errors during the terminal commands. When I finished, all I saw in my repository was the README.md file and nothing else.

I tried to check at my terminal to see if my login name matched the Github username of the target repository. But I didn't see any commands for checking the login name at the terminal.

OS/config: Using OS X 10.10.5 (Yosemite) on MacBook Air

Code

I tried this...
git init
git add README.md # This is the problem. (See my answer below.) Should be "git add ."
git commit -m "first commit"
git remote add origin https://github.com/"username"/"repository".git
git push -u origin master
Let Me Tink About It
  • 15,156
  • 21
  • 98
  • 207

2 Answers2

1

Heres a basic push to GitHub, What kind of errors are you getting?

create a new repository on the command line

git init
git add .      //This will add everything in the directory
git commit -m "first commit"
git remote add origin https://github.com/"username"/"repository".git
git push -u origin master

…or push an existing repository from the command line

git remote add origin https://github.com/"username"/"repository".git
git push -u origin master
Community
  • 1
  • 1
NooBskie
  • 3,761
  • 31
  • 51
  • Those are the steps I followed (described in paragraph two of the question). I saw no errors. Just no files were uploaded to the repo. – Let Me Tink About It Oct 20 '15 at 02:43
  • 1
    `git add .` You tried this one specifically? Github on inital repo create will tell you to run `git add README.md` – NooBskie Oct 20 '15 at 02:43
  • Now I'm getting the error... "fatal: remote origin already exists." when I attempt the command: `git remote add origin https://github.com/"username"/"repository".git` – Let Me Tink About It Oct 20 '15 at 02:50
  • 1
    just delete the repo you made remake a new one on github then change the values `username` and `repository` to the values you need. without quotes of course. your close haha – NooBskie Oct 20 '15 at 02:51
0

Here is what solved the problem for me...

That second git command line should be git add . not git add README.md. The . adds all the files in the directory, as mentioned by the accepted answer.

Code

Solution
git init
git add .  # This was the key line to change from what was tried in the question.
git commit -m "first commit"
git remote add origin https://github.com/username/repository
git push -u origin master
Let Me Tink About It
  • 15,156
  • 21
  • 98
  • 207