Paulos3000
Paulos3000

Reputation: 3545

Pushing repo to remote repository (GitHub)

I'm new to Git/GitHub. Trying to push my files to a new repo I have set up and it's not working. Here's my process:

  1. Set up repo on GitHub.
  2. Initialise remote on repo. git remote add origiN <URL>
  3. Check it's ok. git remote -v

This seems to all go to plan, as Terminal returns

origiN  <URL> (fetch)
origiN  <URL> (push)

...as expected.

Then, when I run git push, I get:

fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

...but I thought I had already configured the remote repository?

What am I missing?

Upvotes: 0

Views: 174

Answers (2)

larsks
larsks

Reputation: 312770

psydroyd answered whilst I was typing, but here is slightly more detail:

A repository can have multiple remotes. You can push to a remote explicitly by running:

git push <remote> <branch>

But if you want git push to work without any additional parameters, you can use the --set-upstream option, aka -u, as in:

git push -u origin master

This sets up your local branch to track the remote master branch. After this point, you can run:

git push

Upvotes: 2

psydroyd
psydroyd

Reputation: 17

git push -u origin master

then you can just git push

Upvotes: 2

Related Questions