git pull origin master returns fatal: invalid refspec
Asked Answered
S

3

24

Here is the problem:

Whenever I do

$ git pull 'https://github.com/username/reponame.github.io.git'

followed by the url I get no problems but when I do

git pull origin master 'https://github.com/username/reponame.github.io.git'

followed by the url it returns

fatal: Invalid refspec 'https://github.com/username/reponame.github.io.git'

What does this mean and how should I go about fixing it?

Sharpie answered 18/10, 2013 at 0:18 Comment(0)
L
16

If you have already established remote-tracking branches (i.e. git clone does this automatically) and want to use git pull with the intention of grabbing and merging the latest commits for the current branch off the remote repository, I believe that executing the following will suffice:

git pull

To achieve the same effect with the inclusion of a refspec (unnecessarily long-winded):

// Pulls the remote 'master' branch down to the local 'master' branch
git pull origin master:refs/remotes/origin/master

You are receiving that error because the provision of a URL is not how the refspec is formatted.

For further details on how the refspec works and its syntax, consult this chapter from the wonderful Pro Git book. Hope that helps!

Lactic answered 18/10, 2013 at 2:23 Comment(0)
E
3

If you'd like to pull the branch "master" from a repo using its explicit URL, then the command to call would be:

git pull https://github.com/username/reponame.github.io.git master

Because "origin" is just a name of a so-called "named remote" which is sort of a configured alias for a repository which allows you to not type that repo's URL each time you access it.

The canonical call to git pull is:

git pull [<repo> [<refspec> ...]]

Where parts in [...] are optional — see the manual page.

Enhance answered 18/10, 2013 at 10:42 Comment(0)
C
0

Go to .git folder there would be a file named config Edit that file, remove the fetch = + line with the bad branch, save and pull/fetch normally

Circuitous answered 2/5 at 5:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.