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?
A refspec maps a branch in the local repository to a branch in a remote repository. This makes it possible to manage remote branches using local Git commands and to configure some advanced git push and git fetch behavior.
Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“. To pull the changes from the remote repository to local, we use git pull along with remote repository “origin” and “master” branch.
Git Push Origin pushes all the branches to the main branch. Git Push Origin Master pushes your master branch to the origin. Command for this: git push origin.
The “… does not a appear to be a git repository” error is triggered when you try to clone, or run other commands, in a directory that is not recognized as a Git repository. The directory or remote file path might not have initialized Git, or the file path you are trying to access as an active repository is incorrect.
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!
Please explain what your git pull origin master 'https://github.com/username/reponame.github.io.git'
call is supposed to do (in your own mind)?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With