0

I frequently want to do this, but can never remember how.

First I create a file on my computer, some source code, and now I want to push it to a github repo.

So I create a github repo. (On github) Click "clone" to get the URL for later.

Now I run the following commands on my local machine.

git init // make a repo, local
git add * // add files to repo
git commit -a -m "initial commit" // commit files to repo and add msg
git remote add origin (...url...) // tell git where to push
git push --set-upstream origin master // no idea what this does
git config --global user.name "...name..." // set my name so github knows what my username is
git push // does not work error:

To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

Still can't "push". What am I doing wrong?

FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
  • Possible duplicate of [Default behavior of "git push" without a branch specified](https://stackoverflow.com/questions/948354/default-behavior-of-git-push-without-a-branch-specified) – phd Aug 10 '17 at 18:22
  • Is the code block in your question a log of the commands you actually ran? Because if you try running `git push --set-upstream origin master` after you have run the `git remote add origin ` command, it should work for you. – instantepiphany Aug 15 '17 at 13:08

1 Answers1

0

Try cloning, then cd into the repo. After, add *. Then run your desired commit and push. This should work. If i were to do this without making any branches, it would look like this:

> git clone 'repoName'
> cd repoName 
> git add *
> git commit -m "first commit"
> git push
Jsleshem
  • 715
  • 1
  • 10
  • 31