Vikas Sharma
Vikas Sharma

Reputation: 1245

local repository origin does not exist

Currently, git bash in windows pointing to vikas@VIKAS-PC /D/code/myrepo (master)

I ran following git commands:

$ git config --global user.name "Vikas Sharma" 
$ git config --global user.email "[email protected]"

git init 
git add . 
git commit -m "initial commit"

$ git status 
On branch master nothing to commit (working directory clean)

Now, "git remote" command returns nothing. I was expecting origin repo.

So, i created origin repo as shown below:

$ git remote add origin D:/code/myrepo

$ git push origin "some-external-repo"

But, getting below error:

error: src refspec myrepo does not match any.
error: failed to push some refs to 'D:/code/myrepo'

Upvotes: 2

Views: 11287

Answers (2)

Vikas Sharma
Vikas Sharma

Reputation: 1245

finally, I am able to resolve it.

I mistakenly thought that below command will create local repository with name "origin":

$ git remote add origin D:/code/myrepo

However, later I realised that "master" is the name of local repository. we don't need to create them explicitly.

now, below command works for me:

$ git push "some-external-repo" master

Thanks anonfunc for helping me on this.

Upvotes: 0

Dwight Holman
Dwight Holman

Reputation: 1610

Following along with your steps:

git init   # You now have a .git directory
git add .  # You've added the working directory files to the index
git commit -m "initial commit" # You now have one commit.

None of these steps give you a remote.

git remote add origin D:/code/myrepo  # Claims that a remote is located there
git push origin # Tries to push to it.

Without manually creating a repo with 'git init' at D:/code/myrepo, this will fail. Git will not create a repo for you at the remote location.

Upvotes: 4

Related Questions