Paulos3000 Paulos3000 - 2 months ago 11x
Git Question

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) 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?


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