Henry
Henry

Reputation: 1755

Why can't I push my local Git repo to my remote?

I'm a novice git user and I'm getting rather confused about something. I'm trying to put all of the code for my current project in a local repo and then push it to the remote repo so that it is backed up even if my local machine crashes hard.

I've done the following to add all the files in my project to the local repo:

$ git init
$ git config user.name 'My Name'
$ git config user.email [email protected]
$ git add .
$ git ls-files

The last of those is, of course, only needed to confirm that the files are on the local repo and, sure enough, the files are there. (I probably need to add a git ignore but I'll do that later.)

So now I want to push the local repo to a remote one. I've already set up a repo in GitHub and initialized it with a README. Let's say its name is MyID\vuetify02. I did the following commands, first to add the remote repo, then to confirm that the remote repo was added:

$ git remote add remote vuetify02 https://github.com/MyID/vuetify02
$ git remote -v

The latter of those commands gave me this:

vuetify02       https://github.com/MyID/vuetify02 (fetch)
vuetify02       https://github.com/MyID/vuetify02 (push)

So far, so good. This is what I expected and it seems to confirm that it sees the remote repo and is satisfied that it exists.

Then I tried doing this, assuming that I'd now established a connection with my remote repo and established an alias that mapped vuetify02 to the exact remote repo I wanted:

git push vuetify02

but got this error:

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream vuetify02 master

Is this git's way of having me establish which branch of the remote repo it is supposed to use for my push? I only have a master branch there so far so I assumed it would default to that if I didn't specify a branch. I'm probably wrong on that though and it needs to be told explicitly what branch to use, even if there is only one. Anyway I tried doing that exact command and got:

remote: Repository not found.
fatal: repository 'https://github.com/MyID/vuetify02/' not found

I'm baffled! Why can't it find the repository? I know the remote repo is there and I can't see any typos in the command so it should work, right?

I'd appreciate some clarification on what I'm not understanding correctly.

Upvotes: 1

Views: 583

Answers (2)

Pankaj Saini
Pankaj Saini

Reputation: 1648

You are using the https URL so you need to pass the user details too in the remote url

Please first do -

git remote set-url vuetify02 https://<MY_USER_NAME>@github.com/<MY_USER_NAME>/vuetify02.git 

Upvotes: 1

Shahryar Saljoughi
Shahryar Saljoughi

Reputation: 3059

You have given your remote repository an alias name that you should use: remote!
Hence the correct command is :

git push --set-upstream remote master

Upvotes: 0

Related Questions